Fix bug where dependencies were parsing argv

This commit is contained in:
Christian Bundy 2019-08-13 10:32:55 -07:00
parent b0260ecaa1
commit 37d3cd590c
No known key found for this signature in database
GPG Key ID: EB541AAEF4366237
2 changed files with 20 additions and 10 deletions

View File

@ -8,25 +8,28 @@ const config = yargs
.env('OASIS')
.usage('Usage: $0 [options]')
.options('open', {
describe: 'automatically open app in web browser',
describe: 'Automatically open app in web browser',
default: true,
type: 'boolean'
})
.options('web-host', {
describe: 'hostname for web app to listen on',
.options('host', {
describe: 'Hostname for web app to listen on',
default: 'localhost',
type: 'string'
type: 'string',
alias: 'web-host' // deprecated
})
.options('web-port', {
describe: 'port for web app to listen on',
.options('port', {
describe: 'Set port for web app to listen on',
default: 3000,
type: 'number'
type: 'number',
alias: 'web-port' // deprecated
})
.options('debug', {
describe: 'verbose output for debugging',
describe: 'Use verbose output for debugging',
default: false,
type: 'boolean'
})
.argv
console.log(config)
app(config)

View File

@ -1,6 +1,13 @@
'use strict'
module.exports = (config) => {
// This hides arguments from other upstream modules who might parse them.
//
// Unfortunately some modules think that our CLI options are meant for them,
// and since there's no way to disable that behavior (!) we have to hide them
// manually by setting the args property to an empty array.
process.argv = []
if (config.debug) {
process.env.DEBUG = '*'
}
@ -107,8 +114,8 @@ module.exports = (config) => {
app.use(router.routes())
const host = config['web-host']
const port = config['web-port']
const host = config.host
const port = config.port
const uri = `http://${host}:${port}/`
debug.enabled = true