Skip to content

Commit c595eda

Browse files
fix(validateOptions): throw err instead of process.exit(1) (#17)
1 parent c723791 commit c595eda

File tree

2 files changed

+22
-36
lines changed

2 files changed

+22
-36
lines changed

package.json

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,12 @@
44
"description": "Webpack Schema Validation Utilities",
55
"license": "MIT",
66
"main": "dist/cjs.js",
7+
"engines": {
8+
"node": ">= 4.8 < 5.0.0 || >= 5.10"
9+
},
710
"files": [
811
"dist"
912
],
10-
"author": "Webpack Contrib (https://github.com/webpack-contrib)",
11-
"contributors": [
12-
"Juho Vepsäläinen <@bebraw>",
13-
"Joshua Wiens <@d3viant0ne>",
14-
"Michael Ciniawsky <@michael-ciniawsky>"
15-
],
1613
"scripts": {
1714
"start": "npm run build -- -w",
1815
"prebuild": "npm run clean",
@@ -21,9 +18,9 @@
2118
"lint": "eslint --cache src test",
2219
"lint-staged": "lint-staged",
2320
"security": "nsp check",
24-
"test": "cross-env JEST=true jest",
25-
"test:watch": "cross-env JEST=true jest --watch",
26-
"test:coverage": "cross-env JEST=true jest --collectCoverageFrom='src/**/*.js' --coverage",
21+
"test": "cross-env jest",
22+
"test:watch": "cross-env jest --watch",
23+
"test:coverage": "cross-env jest --collectCoverageFrom='src/**/*.js' --coverage",
2724
"travis:lint": "npm run lint && npm run security",
2825
"travis:test": "npm run test -- --runInBand",
2926
"travis:coverage": "npm run test:coverage -- --runInBand",
@@ -34,8 +31,7 @@
3431
},
3532
"dependencies": {
3633
"ajv": "^5.0.0",
37-
"ajv-keywords": "^2.1.0",
38-
"chalk": "^2.3.0"
34+
"ajv-keywords": "^2.1.0"
3935
},
4036
"devDependencies": {
4137
"babel-cli": "^6.0.0",
@@ -53,15 +49,24 @@
5349
"nsp": "^2.0.0",
5450
"pre-commit": "^1.0.0",
5551
"standard-version": "^4.0.0",
56-
"webpack": "^3.8.1",
52+
"webpack": "^3.0.0",
5753
"webpack-defaults": "^1.6.0"
5854
},
5955
"peerDependencies": {
6056
"webpack": "^2.0.0 || ^3.0.0"
6157
},
62-
"engines": {
63-
"node": ">= 4.8 < 5.0.0 || >= 5.10"
64-
},
58+
"keywords": [
59+
"webpack",
60+
"webpack-plugin",
61+
"schema-utils",
62+
"loader"
63+
],
64+
"author": "Webpack Contrib (https://github.com/webpack-contrib)",
65+
"contributors": [
66+
"Juho Vepsäläinen <@bebraw>",
67+
"Joshua Wiens <@d3viant0ne>",
68+
"Michael Ciniawsky <@michael-ciniawsky>"
69+
],
6570
"repository": "https://github.com/webpack-contrib/schema-utils.git",
6671
"bugs": "https://github.com/webpack-contrib/schema-utils/issues",
6772
"homepage": "https://github.com/webpack-contrib/schema-utils#readme",
@@ -71,11 +76,5 @@
7176
"eslint --fix",
7277
"git add"
7378
]
74-
},
75-
"keywords": [
76-
"webpack",
77-
"webpack-plugin",
78-
"schema-utils",
79-
"loader"
80-
]
79+
}
8180
}

src/validateOptions.js

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
import fs from 'fs';
77
import path from 'path';
88

9-
import chalk from 'chalk';
10-
119
import Ajv from 'ajv';
1210
import ajvKeywords from 'ajv-keywords';
1311

@@ -28,18 +26,7 @@ const validateOptions = (schema, options, name) => {
2826
}
2927

3028
if (!ajv.validate(schema, options)) {
31-
try {
32-
throw new ValidationError(ajv.errors, name);
33-
} catch (err) {
34-
console.error(chalk.bold.red(`\n${err.message}\n`));
35-
36-
// rethrow {Error} for testing only
37-
if (process.env.JEST) {
38-
throw err;
39-
}
40-
41-
process.exit(1);
42-
}
29+
throw new ValidationError(ajv.errors, name);
4330
}
4431

4532
return true;

0 commit comments

Comments
 (0)