fixed some validation stuff

This commit is contained in:
Tobias Koppers 2016-09-19 21:51:28 +02:00
parent f1446232c6
commit c675067bcf
4 changed files with 26 additions and 8 deletions

View File

@ -554,11 +554,5 @@ module.exports = function(optimist, argv, convertOptions) {
console.error("Use --help to display the CLI options.");
process.exit(-1); // eslint-disable-line
}
var webpackOptionsValidationErrors = validateWebpackOptions(options);
if(webpackOptionsValidationErrors.length) {
console.error("Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema. The following checks have failed.", webpackOptionsValidationErrors);
process.exit(-1); // eslint-disable-line
}
}
};

View File

@ -264,7 +264,20 @@ function processOptions(options) {
Error.stackTraceLimit = 30;
var lastHash = null;
var compiler = webpack(options);
var compiler;
try {
compiler = webpack(options);
} catch(e) {
var WebpackOptionsValidationError = require("../lib/WebpackOptionsValidationError");
if(e instanceof WebpackOptionsValidationError) {
if(argv.color)
console.error("\u001b[1m\u001b[31m" + e.message + "\u001b[39m\u001b[22m");
else
console.error(e.message);
process.exit(1);
}
throw e;
}
if(argv.progress) {
var ProgressPlugin = require("../lib/ProgressPlugin");

View File

@ -7,7 +7,6 @@ var Template = require("./Template");
function WebpackOptionsDefaulter() {
OptionsDefaulter.call(this);
this.set("debug", false);
this.set("devtool", false);
this.set("cache", true);

View File

@ -382,6 +382,18 @@
}
]
},
"hashFunction": {
"type": "string",
"minLength": 1
},
"hashDigest": {
"type": "string",
"minLength": 1
},
"hashDigestLength": {
"type": "number",
"minimum": 1
},
"chunkFilename": {
"description": "The filename of non-entry chunks as relative path inside the `output.path` directory.",
"type": "string"