This commit is contained in:
bkmartinjr
2018-05-05 13:15:10 -07:00
parent d91d42f2c4
commit 90c7daf571
62 changed files with 2398 additions and 1912 deletions
+21 -20
View File
@@ -1,7 +1,8 @@
/* eslint-disable */
var chalk = require('chalk');
// jshint esversion: 6
var chalk = require("chalk");
var friendlySyntaxErrorLabel = 'Syntax error:';
var friendlySyntaxErrorLabel = "Syntax error:";
function isLikelyASyntaxError(message) {
return message.indexOf(friendlySyntaxErrorLabel) !== -1;
@@ -9,16 +10,16 @@ function isLikelyASyntaxError(message) {
function formatMessage(message) {
return message
.replace('Module build failed: SyntaxError:', friendlySyntaxErrorLabel)
.replace("Module build failed: SyntaxError:", friendlySyntaxErrorLabel)
.replace(
/Module not found: Error: Cannot resolve 'file' or 'directory'/,
'Module not found:'
"Module not found:"
)
.replace(/^\s*at\s.*:\d+:\d+[\s\)]*\n/gm, '')
.replace('./~/css-loader!./~/postcss-loader!', '');
.replace(/^\s*at\s.*:\d+:\d+[\s\)]*\n/gm, "")
.replace("./~/css-loader!./~/postcss-loader!", "");
}
var clearConsole = () => {
process.stdout.write('\x1bc');
process.stdout.write("\x1bc");
};
var formatStats = (stats, port) => {
@@ -26,23 +27,23 @@ var formatStats = (stats, port) => {
var hasErrors = stats.hasErrors();
var hasWarnings = stats.hasWarnings();
if (!hasErrors && !hasWarnings) {
console.log(chalk.green('Compiled successfully!'));
console.log(chalk.green("Compiled successfully!"));
console.log();
console.log('The app is running at http://localhost:' + port + '/');
console.log("The app is running at http://localhost:" + port + "/");
console.log();
return;
}
var json = stats.toJson();
var formattedErrors = json.errors.map(
message => 'Error in ' + formatMessage(message)
message => "Error in " + formatMessage(message)
);
var formattedWarnings = json.warnings.map(
message => 'Warning in ' + formatMessage(message)
message => "Warning in " + formatMessage(message)
);
if (hasErrors) {
console.log(chalk.red('Failed to compile.'));
console.log(chalk.red("Failed to compile."));
console.log();
if (formattedErrors.some(isLikelyASyntaxError)) {
formattedErrors = formattedErrors.filter(isLikelyASyntaxError);
@@ -55,23 +56,23 @@ var formatStats = (stats, port) => {
}
if (hasWarnings) {
console.log(chalk.yellow('Compiled with warnings.'));
console.log(chalk.yellow("Compiled with warnings."));
console.log();
formattedWarnings.forEach(message => {
console.log(message);
console.log();
});
console.log('You may use special comments to disable some warnings.');
console.log("You may use special comments to disable some warnings.");
console.log(
'Use ' +
chalk.yellow('// eslint-disable-next-line') +
' to ignore the next line.'
"Use " +
chalk.yellow("// eslint-disable-next-line") +
" to ignore the next line."
);
console.log(
'Use ' +
chalk.yellow('/* eslint-disable */') +
' to ignore all warnings in a file.'
"Use " +
chalk.yellow("/* eslint-disable */") +
" to ignore all warnings in a file."
);
}
};