From a8e275db9ecd64bf05543680f03b7edbcaf35c2a Mon Sep 17 00:00:00 2001 From: Mateusz Rutkiewicz Date: Fri, 14 Dec 2018 12:24:41 +0100 Subject: [PATCH] 17899: [CLI] better logging of webpack errors --- .../webpack/formatWebpackErrorMessages.ts | 19 +++++++++++-------- .../watch/whenComponentHasSyntaxError.test.ts | 2 +- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/packages/uxpin-merge-cli/src/utils/webpack/formatWebpackErrorMessages.ts b/packages/uxpin-merge-cli/src/utils/webpack/formatWebpackErrorMessages.ts index cde83c08e..6abd70737 100644 --- a/packages/uxpin-merge-cli/src/utils/webpack/formatWebpackErrorMessages.ts +++ b/packages/uxpin-merge-cli/src/utils/webpack/formatWebpackErrorMessages.ts @@ -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, + }); } diff --git a/packages/uxpin-merge-cli/test/integration/experimentation/watch/whenComponentHasSyntaxError.test.ts b/packages/uxpin-merge-cli/test/integration/experimentation/watch/whenComponentHasSyntaxError.test.ts index 2c484f8de..eb465464f 100644 --- a/packages/uxpin-merge-cli/test/integration/experimentation/watch/whenComponentHasSyntaxError.test.ts +++ b/packages/uxpin-merge-cli/test/integration/experimentation/watch/whenComponentHasSyntaxError.test.ts @@ -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', () => {