Skip to content

Commit

Permalink
replace color properties with safe-mode calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Leon Weidauer authored and BigBlueHat committed May 1, 2017
1 parent a3ace13 commit 0da0e1b
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions bin/http-server
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ if (!argv.s && !argv.silent) {
if (error) {
logger.info(
'[%s] "%s %s" Error (%s): "%s"',
date, req.method.red, req.url.red,
error.status.toString().red, error.message.red
date, colors.red(req.method), colors.red(req.url),
colors.red(error.status.toString()), colors.red(error.message)
);
}
else {
logger.info(
'[%s] "%s %s" "%s"',
date, req.method.cyan, req.url.cyan,
date, colors.cyan(req.method), colors.cyan(req.url),
req.headers['user-agent']
);
}
Expand Down Expand Up @@ -123,20 +123,20 @@ function listen(port) {
var canonicalHost = host === '0.0.0.0' ? '127.0.0.1' : host,
protocol = ssl ? 'https://' : 'http://';

logger.info(['Starting up http-server, serving '.yellow,
server.root.cyan,
ssl ? (' through'.yellow + ' https'.cyan) : '',
'\nAvailable on:'.yellow
logger.info([colors.yellow('Starting up http-server, serving '),
colors.cyan(server.root),
ssl ? (colors.yellow(' through') + colors.cyan(' https')) : '',
colors.yellow('\nAvailable on:')
].join(''));

if (argv.a && host !== '0.0.0.0') {
logger.info((' ' + protocol + canonicalHost + ':' + port.toString()).green);
logger.info((' ' + protocol + canonicalHost + ':' + colors.green(port.toString())));
}
else {
Object.keys(ifaces).forEach(function (dev) {
ifaces[dev].forEach(function (details) {
if (details.family === 'IPv4') {
logger.info((' ' + protocol + details.address + ':' + port.toString()).green);
logger.info((' ' + protocol + details.address + ':' + colors.green(port.toString())));
}
});
});
Expand Down Expand Up @@ -166,11 +166,11 @@ if (process.platform === 'win32') {
}

process.on('SIGINT', function () {
logger.info('http-server stopped.'.red);
logger.info(colors.red('http-server stopped.'));
process.exit();
});

process.on('SIGTERM', function () {
logger.info('http-server stopped.'.red);
logger.info(colors.red('http-server stopped.'));
process.exit();
});

0 comments on commit 0da0e1b

Please sign in to comment.