Skip to content

Commit

Permalink
fix(validateOptions): throw err instead of process.exit(1) (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-ciniawsky committed Dec 4, 2017
1 parent c723791 commit c595eda
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 36 deletions.
43 changes: 21 additions & 22 deletions package.json
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
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

0 comments on commit c595eda

Please sign in to comment.