Skip to content

Commit

Permalink
Tweak colors for better contrast on Windows (facebook#2180)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon authored May 16, 2017
1 parent 87868a2 commit a7c5c7a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
33 changes: 21 additions & 12 deletions scripts/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,35 @@ const HOST = process.env.HOST || '0.0.0.0';
function run(port) {
const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';

const formatUrl = hostname =>
url.format({ protocol, hostname, port, pathname: '/' });
const formatUrl = hostname => url.format({
protocol,
hostname,
port,
pathname: '/',
});
const prettyPrintUrl = hostname => url.format({
protocol,
hostname,
port: chalk.bold(port),
pathname: '/',
});

const isUnspecifiedAddress = HOST === '0.0.0.0' || HOST === '::';
let prettyHost, lanAddress;
let prettyHost, lanAddress, prettyLanUrl;
if (isUnspecifiedAddress) {
prettyHost = 'localhost';
try {
lanAddress = address.ip();
if (lanAddress) {
prettyLanUrl = prettyPrintUrl(lanAddress);
}
} catch (_e) {
// ignored
}
} else {
prettyHost = HOST;
}
const prettyUrl = formatUrl(prettyHost);
const prettyLocalUrl = prettyPrintUrl(prettyHost);

// Create a webpack compiler that is configured with custom messages.
const compiler = createWebpackCompiler(
Expand All @@ -85,15 +98,11 @@ function run(port) {
);
console.log();

if (isUnspecifiedAddress && lanAddress) {
console.log(
` ${chalk.bold('Local:')} ${chalk.cyan(prettyUrl)}`
);
console.log(
` ${chalk.bold('On Your Network:')} ${chalk.cyan(formatUrl(lanAddress))}`
);
if (prettyLanUrl) {
console.log(` ${chalk.bold('Local:')} ${prettyLocalUrl}`);
console.log(` ${chalk.bold('On Your Network:')} ${prettyLanUrl}`);
} else {
console.log(` ${chalk.cyan(prettyUrl)}`);
console.log(` ${prettyLocalUrl}`);
}

console.log();
Expand Down
6 changes: 3 additions & 3 deletions scripts/utils/createWebpackCompiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@ module.exports = function createWebpackCompiler(config, onReadyCallback) {
// Teach some ESLint tricks.
console.log(
'Search for the ' +
chalk.underline('rule keywords') +
chalk.underline(chalk.yellow('rule keywords')) +
' to learn more about each warning.'
);
console.log(
'To ignore, add ' +
chalk.yellow('// eslint-disable-next-line') +
' to the previous line.'
chalk.cyan('// eslint-disable-next-line') +
' to the line before.'
);
console.log();
}
Expand Down

0 comments on commit a7c5c7a

Please sign in to comment.