Fix bug where --host and --port don't work

See: https://github.com/ssbc/ssb-config/issues/56
This commit is contained in:
Christian Bundy
2019-06-30 13:37:58 -07:00
parent 888d0152d6
commit fced88dcbd
2 changed files with 11 additions and 8 deletions

View File

@ -11,18 +11,18 @@ const config = yargs
default: true, default: true,
type: 'boolean' type: 'boolean'
}) })
.options('host', { .options('web-host', {
describe: 'hostname to listen on', describe: 'hostname for web app to listen on',
default: 'localhost', default: 'localhost',
type: 'string' type: 'string'
}) })
.options('port', { .options('web-port', {
describe: 'port to listen on', describe: 'port for web app to listen on',
default: 3000, default: 3000,
type: 'number' type: 'number'
}) })
.options('debug', { .options('debug', {
describe: 'console debug output', describe: 'verbose output for debugging',
default: false, default: false,
type: 'boolean' type: 'boolean'
}) })

View File

@ -42,11 +42,14 @@ module.exports = (config) => {
app.use(router.routes()) app.use(router.routes())
const uri = `http://${config.host}:${config.port}/` const host = config['web-host']
app.listen(config.port) const port = config['web-port']
const uri = `http://${host}:${port}/`
debug.enabled = true debug.enabled = true
debug(`Listening on http://${uri}`) debug(`Listening on ${uri}`)
app.listen({ host, port })
if (config.open === true) { if (config.open === true) {
open(uri) open(uri)