Skip to content

Commit

Permalink
electron version without URL
Browse files Browse the repository at this point in the history
  • Loading branch information
nucleardreamer committed Jan 13, 2018
1 parent 9281f54 commit 651f70c
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,11 @@ program
v => v.split(','), []
)
.option(
'--electron-version',
'--electronVersion',
'Print electron version'
)
.arguments('<url>')
.action(function (url, options) {
if (_.has(options, 'electronVersion')) {
console.log(electronVersion)
process.exit(0)
}
if (url) {
opts.url = url
}
Expand All @@ -163,17 +159,22 @@ if (_.get(process.env, 'CHROME_DESKTOP') === 'oak.desktop' || basename(process.a

program.parse(tmpArgv)

if (program.electronVersion) {
console.log(electronVersion)
process.exit(0)
}

if (!program.url) {
program.help()
}

opts = _(program._events)
.omit('*', 'version', 'electronVersion')
.mapValues((v, k) => program[k])
.omitBy(_.isUndefined)
.merge(opts)
.value()

if (!opts.url) {
program.help()
}

if (require('url').parse(opts.url).protocol !== null) {
// if the url argument is an actual URI, just load it
oak.on('ready', () => oak.load(opts))
Expand Down

0 comments on commit 651f70c

Please sign in to comment.