From 75a8d6a620e77adb45ba2c25b6600cbb36632883 Mon Sep 17 00:00:00 2001 From: Leo Lamprecht Date: Sat, 4 Feb 2017 11:59:14 +0100 Subject: [PATCH] Beautiful notification when running --- lib/listening.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/listening.js b/lib/listening.js index 3f1c6c1c..7f1cfdcc 100644 --- a/lib/listening.js +++ b/lib/listening.js @@ -2,7 +2,7 @@ const {copy} = require('copy-paste') const ip = require('ip') const pathType = require('path-type') -const {red, grey} = require('chalk') +const chalk = require('chalk') const copyToClipboard = async text => { try { @@ -24,18 +24,26 @@ module.exports = async (server, current) => { }) if (!await pathType.dir(current)) { - console.error(red('Specified directory doesn\'t exist!')) + console.error(chalk.red('Specified directory doesn\'t exist!')) process.exit(1) } if (!process.env.NOW) { - let message = `Running on ${url}` + let message = chalk.green('Serving!') + message += '\n\n' + + const localURL = `http://localhost:${details.port}` + + message += `• ${chalk.bold('Locally: ')} ${localURL}\n` + message += `• ${chalk.bold('On the Network: ')} ${url}\n\n` + const copied = await copyToClipboard(url) if (copied) { - message = `${message} ${grey('[copied to clipboard]')}` + message += `${chalk.grey('Copied local address to clipboard!')}\n\n` } - console.log(message) + process.stdout.write('\x1Bc') + process.stdout.write(message) } }