diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-12-10 21:51:33 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-12-10 21:51:33 +0100 |
commit | 0469abd4a9c9270a1fdc962969e36e63699af8b4 (patch) | |
tree | f9864d4a4148621378958794cbbfdc2393733283 /node_modules/webpack/lib/WebpackOptionsValidationError.js | |
parent | 6947e79bbc258f7bc96af424ddb71a511f0c15a3 (diff) |
upgrade dependencies
Diffstat (limited to 'node_modules/webpack/lib/WebpackOptionsValidationError.js')
-rw-r--r-- | node_modules/webpack/lib/WebpackOptionsValidationError.js | 45 |
1 files changed, 34 insertions, 11 deletions
diff --git a/node_modules/webpack/lib/WebpackOptionsValidationError.js b/node_modules/webpack/lib/WebpackOptionsValidationError.js index 61cb99bd7..4fa72d19b 100644 --- a/node_modules/webpack/lib/WebpackOptionsValidationError.js +++ b/node_modules/webpack/lib/WebpackOptionsValidationError.js @@ -35,10 +35,21 @@ const getSchemaPartText = (schemaPart, additionalPath) => { while(schemaPart.$ref) schemaPart = getSchemaPart(schemaPart.$ref);
let schemaText = WebpackOptionsValidationError.formatSchema(schemaPart);
if(schemaPart.description)
- schemaText += `\n${schemaPart.description}`;
+ schemaText += `\n-> ${schemaPart.description}`;
return schemaText;
};
+const getSchemaPartDescription = schemaPart => {
+ while(schemaPart.$ref) schemaPart = getSchemaPart(schemaPart.$ref);
+ if(schemaPart.description)
+ return `\n-> ${schemaPart.description}`;
+ return "";
+};
+
+const filterChildren = children => {
+ return children.filter(err => err.keyword !== "anyOf" && err.keyword !== "allOf" && err.keyword !== "oneOf");
+};
+
const indent = (str, prefix, firstLine) => {
if(firstLine) {
return prefix + str.replace(/\n(?!$)/g, "\n" + prefix);
@@ -143,8 +154,16 @@ class WebpackOptionsValidationError extends WebpackError { return baseMessage;
} else if(err.keyword === "oneOf" || err.keyword === "anyOf") {
if(err.children && err.children.length > 0) {
+ if(err.schema.length === 1) {
+ const lastChild = err.children[err.children.length - 1];
+ const remainingChildren = err.children.slice(0, err.children.length - 1);
+ return WebpackOptionsValidationError.formatValidationError(Object.assign({}, lastChild, {
+ children: remainingChildren,
+ parentSchema: Object.assign({}, err.parentSchema, lastChild.parentSchema)
+ }));
+ }
return `${dataPath} should be one of these:\n${getSchemaPartText(err.parentSchema)}\n` +
- `Details:\n${err.children.map(err => " * " + indent(WebpackOptionsValidationError.formatValidationError(err), " ", false)).join("\n")}`;
+ `Details:\n${filterChildren(err.children).map(err => " * " + indent(WebpackOptionsValidationError.formatValidationError(err), " ", false)).join("\n")}`;
}
return `${dataPath} should be one of these:\n${getSchemaPartText(err.parentSchema)}`;
@@ -158,29 +177,33 @@ class WebpackOptionsValidationError extends WebpackError { } else if(err.keyword === "type") {
switch(err.params.type) {
case "object":
- return `${dataPath} should be an object.`;
+ return `${dataPath} should be an object.${getSchemaPartDescription(err.parentSchema)}`;
case "string":
- return `${dataPath} should be a string.`;
+ return `${dataPath} should be a string.${getSchemaPartDescription(err.parentSchema)}`;
case "boolean":
- return `${dataPath} should be a boolean.`;
+ return `${dataPath} should be a boolean.${getSchemaPartDescription(err.parentSchema)}`;
case "number":
- return `${dataPath} should be a number.`;
+ return `${dataPath} should be a number.${getSchemaPartDescription(err.parentSchema)}`;
case "array":
return `${dataPath} should be an array:\n${getSchemaPartText(err.parentSchema)}`;
}
return `${dataPath} should be ${err.params.type}:\n${getSchemaPartText(err.parentSchema)}`;
} else if(err.keyword === "instanceof") {
- return `${dataPath} should be an instance of ${getSchemaPartText(err.parentSchema)}.`;
+ return `${dataPath} should be an instance of ${getSchemaPartText(err.parentSchema)}`;
} else if(err.keyword === "required") {
const missingProperty = err.params.missingProperty.replace(/^\./, "");
return `${dataPath} misses the property '${missingProperty}'.\n${getSchemaPartText(err.parentSchema, ["properties", missingProperty])}`;
- } else if(err.keyword === "minLength" || err.keyword === "minItems") {
+ } else if(err.keyword === "minimum") {
+ return `${dataPath} ${err.message}.${getSchemaPartDescription(err.parentSchema)}`;
+ } else if(err.keyword === "uniqueItems") {
+ return `${dataPath} should not contain the item '${err.data[err.params.i]}' twice.${getSchemaPartDescription(err.parentSchema)}`;
+ } else if(err.keyword === "minLength" || err.keyword === "minItems" || err.keyword === "minProperties") {
if(err.params.limit === 1)
- return `${dataPath} should not be empty.`;
+ return `${dataPath} should not be empty.${getSchemaPartDescription(err.parentSchema)}`;
else
- return `${dataPath} ${err.message}`;
+ return `${dataPath} ${err.message}${getSchemaPartDescription(err.parentSchema)}`;
} else if(err.keyword === "absolutePath") {
- const baseMessage = `${dataPath}: ${err.message}`;
+ const baseMessage = `${dataPath}: ${err.message}${getSchemaPartDescription(err.parentSchema)}`;
if(dataPath === "configuration.output.filename") {
return `${baseMessage}\n` +
"Please use output.path to specify absolute path and output.filename for the file name.";
|