Skip to content
This repository was archived by the owner on Jul 27, 2021. It is now read-only.

Commit 46b2560

Browse files
authored
Remove repeated error path on windows
1 parent 78890c6 commit 46b2560

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

src/output.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class Debugger {
7575

7676
captureConsole (args, method) {
7777
if (this.capturing) {
78-
this.capturedMessages.push(chalk.stripColor(args.join(' ').trim()));
78+
this.capturedMessages.push(chalk.stripColor(args.join(' ')).trim());
7979
} else {
8080
method.apply(console, args);
8181
}

src/transformers/babelSyntax.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ function cleanStackTrace(message) {
1111

1212
function cleanMessage(message) {
1313
return message
14-
.replace('Module build failed: ', '');
14+
// match until the last semicolon followed by a space
15+
// this should match
16+
// linux => "(SyntaxError: )Unexpected token (5:11)"
17+
// windows => "(SyntaxError: C:/projects/index.js: )Unexpected token (5:11)"
18+
.replace(/^Module build failed.*:\s/, 'Syntax Error: ');
1519
}
1620

1721
function isBabelSyntaxError(e) {

test/integration.spec.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ it('integration : module-errors', async () => {
4444
const logs = await executeAndGetLogs('./fixtures/module-errors/webpack.config.js');
4545

4646
expect(logs).toEqual([
47-
' ERROR Failed to compile with 2 errors',
47+
'ERROR Failed to compile with 2 errors',
4848
'',
4949
'These dependencies were not found in node_modules:',
5050
'',
@@ -60,15 +60,14 @@ it('integration : should display eslint warnings', async () => {
6060
const logs = await executeAndGetLogs('./fixtures/eslint-warnings/webpack.config.js');
6161

6262
expect(logs).toEqual([
63-
' WARNING Compiled with 1 warnings',
63+
'WARNING Compiled with 1 warnings',
6464
'',
65-
' warning in ./test/fixtures/eslint-warnings/index.js',
65+
'warning in ./test/fixtures/eslint-warnings/index.js',
6666
'',
6767
`${__dirname}/fixtures/eslint-warnings/index.js
6868
1:7 warning 'unused' is assigned a value but never used no-unused-vars
6969
70-
✖ 1 problem (0 errors, 1 warning)
71-
`,
70+
✖ 1 problem (0 errors, 1 warning)`,
7271
'',
7372
'You may use special comments to disable some warnings.',
7473
'Use // eslint-disable-next-line to ignore the next line.',
@@ -81,11 +80,11 @@ it('integration : babel syntax error', async () => {
8180
const logs = await executeAndGetLogs('./fixtures/babel-syntax/webpack.config');
8281

8382
expect(logs).toEqual([
84-
' ERROR Failed to compile with 1 errors',
83+
'ERROR Failed to compile with 1 errors',
8584
'',
86-
' error in ./test/fixtures/babel-syntax/index.js',
85+
'error in ./test/fixtures/babel-syntax/index.js',
8786
'',
88-
`SyntaxError: Unexpected token (5:11)
87+
`Syntax Error: Unexpected token (5:11)
8988
9089
3 |${' '}
9190
4 | render() {
@@ -113,7 +112,7 @@ it('integration : webpack multi compiler : module-errors', async () => {
113112
const logs = await executeAndGetLogs('./fixtures/multi-compiler-module-errors/webpack.config', globalPlugins);
114113

115114
expect(logs).toEqual([
116-
' ERROR Failed to compile with 2 errors',
115+
'ERROR Failed to compile with 2 errors',
117116
'',
118117
'These dependencies were not found in node_modules:',
119118
'',

test/unit/plugin/friendlyErrors.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ it('friendlyErrors : capture invalid message', () => {
1818
});
1919

2020
expect(logs).toEqual([
21-
' WAIT Compiling...',
21+
'WAIT Compiling...',
2222
''
2323
]);
2424
});
@@ -31,7 +31,7 @@ it('friendlyErrors : capture compilation without errors', () => {
3131
});
3232

3333
expect(logs).toEqual([
34-
' DONE Compiled successfully in 100ms',
34+
'DONE Compiled successfully in 100ms',
3535
''
3636
]);
3737
});

0 commit comments

Comments
 (0)