Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(validateOptions): throw err instead of process.exit(1) #17

Merged
merged 1 commit into from
Dec 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
43 changes: 21 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@
"description": "Webpack Schema Validation Utilities",
"license": "MIT",
"main": "dist/cjs.js",
"engines": {
"node": ">= 4.8 < 5.0.0 || >= 5.10"
},
"files": [
"dist"
],
"author": "Webpack Contrib (https://github.com/webpack-contrib)",
"contributors": [
"Juho Vepsäläinen <@bebraw>",
"Joshua Wiens <@d3viant0ne>",
"Michael Ciniawsky <@michael-ciniawsky>"
],
"scripts": {
"start": "npm run build -- -w",
"prebuild": "npm run clean",
Expand All @@ -21,9 +18,9 @@
"lint": "eslint --cache src test",
"lint-staged": "lint-staged",
"security": "nsp check",
"test": "cross-env JEST=true jest",
"test:watch": "cross-env JEST=true jest --watch",
"test:coverage": "cross-env JEST=true jest --collectCoverageFrom='src/**/*.js' --coverage",
"test": "cross-env jest",
"test:watch": "cross-env jest --watch",
"test:coverage": "cross-env jest --collectCoverageFrom='src/**/*.js' --coverage",
"travis:lint": "npm run lint && npm run security",
"travis:test": "npm run test -- --runInBand",
"travis:coverage": "npm run test:coverage -- --runInBand",
Expand All @@ -34,8 +31,7 @@
},
"dependencies": {
"ajv": "^5.0.0",
"ajv-keywords": "^2.1.0",
"chalk": "^2.3.0"
"ajv-keywords": "^2.1.0"
},
"devDependencies": {
"babel-cli": "^6.0.0",
Expand All @@ -53,15 +49,24 @@
"nsp": "^2.0.0",
"pre-commit": "^1.0.0",
"standard-version": "^4.0.0",
"webpack": "^3.8.1",
"webpack": "^3.0.0",
"webpack-defaults": "^1.6.0"
},
"peerDependencies": {
"webpack": "^2.0.0 || ^3.0.0"
},
"engines": {
"node": ">= 4.8 < 5.0.0 || >= 5.10"
},
"keywords": [
"webpack",
"webpack-plugin",
"schema-utils",
"loader"
],
"author": "Webpack Contrib (https://github.com/webpack-contrib)",
"contributors": [
"Juho Vepsäläinen <@bebraw>",
"Joshua Wiens <@d3viant0ne>",
"Michael Ciniawsky <@michael-ciniawsky>"
],
"repository": "https://github.com/webpack-contrib/schema-utils.git",
"bugs": "https://github.com/webpack-contrib/schema-utils/issues",
"homepage": "https://github.com/webpack-contrib/schema-utils#readme",
Expand All @@ -71,11 +76,5 @@
"eslint --fix",
"git add"
]
},
"keywords": [
"webpack",
"webpack-plugin",
"schema-utils",
"loader"
]
}
}
15 changes: 1 addition & 14 deletions src/validateOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import fs from 'fs';
import path from 'path';

import chalk from 'chalk';

import Ajv from 'ajv';
import ajvKeywords from 'ajv-keywords';

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

if (!ajv.validate(schema, options)) {
try {
throw new ValidationError(ajv.errors, name);
} catch (err) {
console.error(chalk.bold.red(`\n${err.message}\n`));

// rethrow {Error} for testing only
if (process.env.JEST) {
throw err;
}

process.exit(1);
}
throw new ValidationError(ajv.errors, name);
}

return true;
Expand Down