mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-04-24 05:05:53 +08:00
update to modern code style (#1738)
* mv create-react-app/index.js -> create-react-app/creteReactApp.js * update to modern code style * var -> cosnt * set trailing-coma to es5 for prettier
This commit is contained in:
committed by
Dan Abramov
parent
43873dc9b8
commit
fe7b5c212b
@@ -46,18 +46,15 @@ function formatMessage(message) {
|
||||
lines = [
|
||||
lines[0],
|
||||
// Clean up message because "Module not found: " is descriptive enough.
|
||||
lines[1].replace(
|
||||
'Cannot resolve \'file\' or \'directory\' ', ''
|
||||
).replace(
|
||||
'Cannot resolve module ', ''
|
||||
).replace(
|
||||
'Error: ', ''
|
||||
),
|
||||
lines[1]
|
||||
.replace("Cannot resolve 'file' or 'directory' ", '')
|
||||
.replace('Cannot resolve module ', '')
|
||||
.replace('Error: ', ''),
|
||||
// Skip all irrelevant lines.
|
||||
// (For some reason they only appear on the client in browser.)
|
||||
'',
|
||||
lines[lines.length - 1] // error location is the last line
|
||||
]
|
||||
lines[lines.length - 1], // error location is the last line
|
||||
];
|
||||
}
|
||||
|
||||
// Cleans up syntax error messages.
|
||||
@@ -108,7 +105,8 @@ function formatMessage(message) {
|
||||
// from user code generated by WebPack. For more information see
|
||||
// https://github.com/facebookincubator/create-react-app/pull/1050
|
||||
message = message.replace(
|
||||
/^\s*at\s((?!webpack:).)*:\d+:\d+[\s\)]*(\n|$)/gm, ''
|
||||
/^\s*at\s((?!webpack:).)*:\d+:\d+[\s\)]*(\n|$)/gm,
|
||||
''
|
||||
); // at ... ...:x:y
|
||||
|
||||
return message;
|
||||
@@ -116,14 +114,14 @@ function formatMessage(message) {
|
||||
|
||||
function formatWebpackMessages(json) {
|
||||
var formattedErrors = json.errors.map(function(message) {
|
||||
return 'Error in ' + formatMessage(message)
|
||||
return 'Error in ' + formatMessage(message);
|
||||
});
|
||||
var formattedWarnings = json.warnings.map(function(message) {
|
||||
return 'Warning in ' + formatMessage(message)
|
||||
return 'Warning in ' + formatMessage(message);
|
||||
});
|
||||
var result = {
|
||||
errors: formattedErrors,
|
||||
warnings: formattedWarnings
|
||||
warnings: formattedWarnings,
|
||||
};
|
||||
if (result.errors.some(isLikelyASyntaxError)) {
|
||||
// If there are any syntax errors, show just them.
|
||||
|
||||
Reference in New Issue
Block a user