mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-04-29 01:45:40 +08:00
Tweak colors for better contrast on Windows (#2180)
This commit is contained in:
4
packages/react-dev-utils/eslintFormatter.js
vendored
4
packages/react-dev-utils/eslintFormatter.js
vendored
@@ -45,9 +45,9 @@ function formatter(results) {
|
|||||||
messages = messages.filter(m => m[2] === 'error');
|
messages = messages.filter(m => m[2] === 'error');
|
||||||
}
|
}
|
||||||
|
|
||||||
// add color to messageTypes
|
// add color to rule keywords
|
||||||
messages.forEach(m => {
|
messages.forEach(m => {
|
||||||
m[3] = m[2] === 'error' ? chalk.red(m[3]) : chalk.yellow(m[3]);
|
m[4] = m[2] === 'error' ? chalk.red(m[4]) : chalk.yellow(m[4]);
|
||||||
m.splice(2, 1);
|
m.splice(2, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
33
packages/react-scripts/scripts/start.js
vendored
33
packages/react-scripts/scripts/start.js
vendored
@@ -55,22 +55,35 @@ const HOST = process.env.HOST || '0.0.0.0';
|
|||||||
function run(port) {
|
function run(port) {
|
||||||
const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
|
const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
|
||||||
|
|
||||||
const formatUrl = hostname =>
|
const formatUrl = hostname => url.format({
|
||||||
url.format({ protocol, hostname, port, pathname: '/' });
|
protocol,
|
||||||
|
hostname,
|
||||||
|
port,
|
||||||
|
pathname: '/',
|
||||||
|
});
|
||||||
|
const prettyPrintUrl = hostname => url.format({
|
||||||
|
protocol,
|
||||||
|
hostname,
|
||||||
|
port: chalk.bold(port),
|
||||||
|
pathname: '/',
|
||||||
|
});
|
||||||
|
|
||||||
const isUnspecifiedAddress = HOST === '0.0.0.0' || HOST === '::';
|
const isUnspecifiedAddress = HOST === '0.0.0.0' || HOST === '::';
|
||||||
let prettyHost, lanAddress;
|
let prettyHost, lanAddress, prettyLanUrl;
|
||||||
if (isUnspecifiedAddress) {
|
if (isUnspecifiedAddress) {
|
||||||
prettyHost = 'localhost';
|
prettyHost = 'localhost';
|
||||||
try {
|
try {
|
||||||
lanAddress = address.ip();
|
lanAddress = address.ip();
|
||||||
|
if (lanAddress) {
|
||||||
|
prettyLanUrl = prettyPrintUrl(lanAddress);
|
||||||
|
}
|
||||||
} catch (_e) {
|
} catch (_e) {
|
||||||
// ignored
|
// ignored
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
prettyHost = HOST;
|
prettyHost = HOST;
|
||||||
}
|
}
|
||||||
const prettyUrl = formatUrl(prettyHost);
|
const prettyLocalUrl = prettyPrintUrl(prettyHost);
|
||||||
|
|
||||||
// Create a webpack compiler that is configured with custom messages.
|
// Create a webpack compiler that is configured with custom messages.
|
||||||
const compiler = createWebpackCompiler(
|
const compiler = createWebpackCompiler(
|
||||||
@@ -85,15 +98,11 @@ function run(port) {
|
|||||||
);
|
);
|
||||||
console.log();
|
console.log();
|
||||||
|
|
||||||
if (isUnspecifiedAddress && lanAddress) {
|
if (prettyLanUrl) {
|
||||||
console.log(
|
console.log(` ${chalk.bold('Local:')} ${prettyLocalUrl}`);
|
||||||
` ${chalk.bold('Local:')} ${chalk.cyan(prettyUrl)}`
|
console.log(` ${chalk.bold('On Your Network:')} ${prettyLanUrl}`);
|
||||||
);
|
|
||||||
console.log(
|
|
||||||
` ${chalk.bold('On Your Network:')} ${chalk.cyan(formatUrl(lanAddress))}`
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
console.log(` ${chalk.cyan(prettyUrl)}`);
|
console.log(` ${prettyLocalUrl}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log();
|
console.log();
|
||||||
|
|||||||
@@ -104,13 +104,13 @@ module.exports = function createWebpackCompiler(config, onReadyCallback) {
|
|||||||
// Teach some ESLint tricks.
|
// Teach some ESLint tricks.
|
||||||
console.log(
|
console.log(
|
||||||
'Search for the ' +
|
'Search for the ' +
|
||||||
chalk.underline('rule keywords') +
|
chalk.underline(chalk.yellow('rule keywords')) +
|
||||||
' to learn more about each warning.'
|
' to learn more about each warning.'
|
||||||
);
|
);
|
||||||
console.log(
|
console.log(
|
||||||
'To ignore, add ' +
|
'To ignore, add ' +
|
||||||
chalk.yellow('// eslint-disable-next-line') +
|
chalk.cyan('// eslint-disable-next-line') +
|
||||||
' to the previous line.'
|
' to the line before.'
|
||||||
);
|
);
|
||||||
console.log();
|
console.log();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user