Fix bug where dependencies were parsing argv
This commit is contained in:
parent
b0260ecaa1
commit
37d3cd590c
19
index.js
19
index.js
|
@ -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)
|
||||
|
|
11
src/app.js
11
src/app.js
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue