Skip to content

Commit

Permalink
Only show network address if local IP is available
Browse files Browse the repository at this point in the history
  • Loading branch information
leo committed Mar 8, 2017
1 parent a5fe997 commit 89651cc
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/listening.js
Expand Up @@ -19,9 +19,6 @@ const copyToClipboard = coroutine(function * (text) {

module.exports = coroutine(function * (server, current, inUse) {
const details = server.address()
const ipAddress = ip.address()
const url = `http://${ipAddress}:${details.port}`

const isTTY = process.stdout.isTTY

process.on('SIGINT', () => {
Expand Down Expand Up @@ -49,7 +46,15 @@ module.exports = coroutine(function * (server, current, inUse) {
const localURL = `http://localhost:${details.port}`

message += `- ${chalk.bold('Local: ')} ${localURL}\n`
message += `- ${chalk.bold('On Your Network: ')} ${url}\n\n`

try {
const ipAddress = ip.address()
const url = `http://${ipAddress}:${details.port}`

message += `- ${chalk.bold('On Your Network: ')} ${url}\n\n`
} catch (err) {
message += `\n`
}

if (isTTY && process.platform === 'darwin') {
const copied = yield copyToClipboard(localURL)
Expand Down

0 comments on commit 89651cc

Please sign in to comment.