From 59f63037fcbdbb8934b578b9adf5725bc4ae1235 Mon Sep 17 00:00:00 2001 From: Alexander Krasnoyarov Date: Sat, 10 Oct 2020 19:17:14 +0300 Subject: [PATCH] fix: exit code for validation errors --- packages/webpack-cli/lib/utils/Compiler.js | 2 +- test/invalid-schema/invalid-schema.test.js | 9 +++------ test/stats/cli-flags/stats.test.js | 3 ++- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/webpack-cli/lib/utils/Compiler.js b/packages/webpack-cli/lib/utils/Compiler.js index 61f491d5a1a..f9ef18d061f 100644 --- a/packages/webpack-cli/lib/utils/Compiler.js +++ b/packages/webpack-cli/lib/utils/Compiler.js @@ -139,7 +139,7 @@ class Compiler { } else { logger.error(`\n${err}`); } - process.exit(1); + process.exit(2); } } diff --git a/test/invalid-schema/invalid-schema.test.js b/test/invalid-schema/invalid-schema.test.js index 090fdefede9..c107f966f9e 100644 --- a/test/invalid-schema/invalid-schema.test.js +++ b/test/invalid-schema/invalid-schema.test.js @@ -3,21 +3,18 @@ const { run, isWindows } = require('../utils/test-utils'); describe('invalid schema', () => { it('should log webpack error and exit process on invalid config', () => { - const { stderr, stdout, exitCode } = run(__dirname, ['--config', './webpack.config.mock.js']); - console.log({ stderr, stdout, exitCode }); + const { stderr, exitCode } = run(__dirname, ['--config', './webpack.config.mock.js']); expect(stderr).toContain('Invalid configuration object'); - // TODO - Fix exitcode check on windows if (!isWindows) { - expect(exitCode).toEqual(1); + expect(exitCode).toEqual(2); } }); it('should log webpack error and exit process on invalid flag', () => { const { stderr, exitCode } = run(__dirname, ['--mode', 'Yukihira']); expect(stderr).toContain('Invalid configuration object'); - // TODO - Fix exitcode check on windows if (!isWindows) { - expect(exitCode).toEqual(1); + expect(exitCode).toEqual(2); } }); }); diff --git a/test/stats/cli-flags/stats.test.js b/test/stats/cli-flags/stats.test.js index 963c637deb9..7500411a79a 100644 --- a/test/stats/cli-flags/stats.test.js +++ b/test/stats/cli-flags/stats.test.js @@ -1,6 +1,7 @@ /* eslint-disable node/no-extraneous-require */ /* eslint-disable node/no-unpublished-require */ 'use strict'; + const { run, isWebpack5, isWindows } = require('../../utils/test-utils'); const presets = ['normal', 'detailed', 'errors-only', 'errors-warnings', 'minimal', 'verbose', 'none']; @@ -45,7 +46,7 @@ describe('stats flag', () => { } // TODO - Fix exitcode check on windows if (!isWindows) { - expect(exitCode).toEqual(1); + expect(exitCode).toEqual(2); } }); });