Skip to content

Commit

Permalink
fix: exit code for validation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi authored Oct 10, 2020
1 parent 1087800 commit 59f6303
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/webpack-cli/lib/utils/Compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class Compiler {
} else {
logger.error(`\n${err}`);
}
process.exit(1);
process.exit(2);
}
}

Expand Down
9 changes: 3 additions & 6 deletions test/invalid-schema/invalid-schema.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
});
3 changes: 2 additions & 1 deletion test/stats/cli-flags/stats.test.js
Original file line number Diff line number Diff line change
@@ -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'];
Expand Down Expand Up @@ -45,7 +46,7 @@ describe('stats flag', () => {
}
// TODO - Fix exitcode check on windows
if (!isWindows) {
expect(exitCode).toEqual(1);
expect(exitCode).toEqual(2);
}
});
});

0 comments on commit 59f6303

Please sign in to comment.