Browse Source

list all networkInterfaces in serverUp message

master
Lloyd Brookes 9 years ago
parent
commit
b1af3e25a0
  1. 12
      bin/cli.js

12
bin/cli.js

@ -7,6 +7,7 @@ const ansi = require('ansi-escape-sequences')
const loadConfig = require('config-master')
const path = require('path')
const s = require('string-tools')
const os = require('os')
const cli = commandLineArgs(cliOptions.definitions)
const usage = cli.getUsage(cliOptions.usageData)
@ -63,10 +64,17 @@ function halt (err) {
}
function onServerUp () {
const ipList = Object.keys(os.networkInterfaces())
.map(key => os.networkInterfaces()[key])
.reduce((prev, curr) => prev = prev.concat(curr), [])
.filter(iface => iface.family === 'IPv4')
.map(iface => `[underline]{${iface.address}:${options.server.port}}`)
.join(', ')
console.error(ansi.format(
path.resolve(options.server.directory) === process.cwd()
? `serving at [underline]{http://localhost:${options.server.port}}`
: `serving [underline]{${options.server.directory}} at [underline]{http://localhost:${options.server.port}}`
? `serving at `
: `serving [underline]{${options.server.directory}} at ${ipList}`
))
}

Loading…
Cancel
Save