Skip to content

Commit 46eeabc

Browse files
authoredMay 16, 2017
Tweak colors for better contrast on Windows (#2180)
1 parent 134d229 commit 46eeabc

File tree

3 files changed

+26
-17
lines changed

3 files changed

+26
-17
lines changed
 

‎packages/react-dev-utils/eslintFormatter.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ function formatter(results) {
4545
messages = messages.filter(m => m[2] === 'error');
4646
}
4747

48-
// add color to messageTypes
48+
// add color to rule keywords
4949
messages.forEach(m => {
50-
m[3] = m[2] === 'error' ? chalk.red(m[3]) : chalk.yellow(m[3]);
50+
m[4] = m[2] === 'error' ? chalk.red(m[4]) : chalk.yellow(m[4]);
5151
m.splice(2, 1);
5252
});
5353

‎packages/react-scripts/scripts/start.js

+21-12
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,35 @@ const HOST = process.env.HOST || '0.0.0.0';
5555
function run(port) {
5656
const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
5757

58-
const formatUrl = hostname =>
59-
url.format({ protocol, hostname, port, pathname: '/' });
58+
const formatUrl = hostname => url.format({
59+
protocol,
60+
hostname,
61+
port,
62+
pathname: '/',
63+
});
64+
const prettyPrintUrl = hostname => url.format({
65+
protocol,
66+
hostname,
67+
port: chalk.bold(port),
68+
pathname: '/',
69+
});
6070

6171
const isUnspecifiedAddress = HOST === '0.0.0.0' || HOST === '::';
62-
let prettyHost, lanAddress;
72+
let prettyHost, lanAddress, prettyLanUrl;
6373
if (isUnspecifiedAddress) {
6474
prettyHost = 'localhost';
6575
try {
6676
lanAddress = address.ip();
77+
if (lanAddress) {
78+
prettyLanUrl = prettyPrintUrl(lanAddress);
79+
}
6780
} catch (_e) {
6881
// ignored
6982
}
7083
} else {
7184
prettyHost = HOST;
7285
}
73-
const prettyUrl = formatUrl(prettyHost);
86+
const prettyLocalUrl = prettyPrintUrl(prettyHost);
7487

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

88-
if (isUnspecifiedAddress && lanAddress) {
89-
console.log(
90-
` ${chalk.bold('Local:')} ${chalk.cyan(prettyUrl)}`
91-
);
92-
console.log(
93-
` ${chalk.bold('On Your Network:')} ${chalk.cyan(formatUrl(lanAddress))}`
94-
);
101+
if (prettyLanUrl) {
102+
console.log(` ${chalk.bold('Local:')} ${prettyLocalUrl}`);
103+
console.log(` ${chalk.bold('On Your Network:')} ${prettyLanUrl}`);
95104
} else {
96-
console.log(` ${chalk.cyan(prettyUrl)}`);
105+
console.log(` ${prettyLocalUrl}`);
97106
}
98107

99108
console.log();

‎packages/react-scripts/scripts/utils/createWebpackCompiler.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,13 @@ module.exports = function createWebpackCompiler(config, onReadyCallback) {
104104
// Teach some ESLint tricks.
105105
console.log(
106106
'Search for the ' +
107-
chalk.underline('rule keywords') +
107+
chalk.underline(chalk.yellow('rule keywords')) +
108108
' to learn more about each warning.'
109109
);
110110
console.log(
111111
'To ignore, add ' +
112-
chalk.yellow('// eslint-disable-next-line') +
113-
' to the previous line.'
112+
chalk.cyan('// eslint-disable-next-line') +
113+
' to the line before.'
114114
);
115115
console.log();
116116
}

0 commit comments

Comments
 (0)