Skip to content

Commit

Permalink
17899: [CLI] better logging of webpack errors
Browse files Browse the repository at this point in the history
  • Loading branch information
devfive committed Dec 14, 2018
1 parent 8b08e4b commit a8e275d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { Stats } from 'webpack';

export function formatWebpackErrorMessages(stats:Stats):string {
const errors:any = stats.toJson({ errors: true });
return errors.errors
.filter(withoutModuleBuildFailed)
.join('\n');
}

function withoutModuleBuildFailed(error:string):boolean {
return error.indexOf('Module build failed') === -1;
return stats.toString({
assets: false,
chunkModules: false,
colors: true,
entrypoints: false,
errors: true,
hash: false,
modules: false,
timings: false,
version: false,
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export default class Avatar extends PureComponent {
});

it('should display Parsing error message on stderr', () => {
expect(errorResponse).toMatch(/ERROR: \.\/src\/components\/Avatar\/Avatar\.jsx/);
expect(errorResponse).toContain('ERROR in ./src/components/Avatar/Avatar.jsx');
});

describe('when user fix content syntax error', () => {
Expand Down

0 comments on commit a8e275d

Please sign in to comment.