Skip to content

Commit 8ecae31

Browse files
committed
clean up schema check output by adding absolutePath explicitly to WebpackOptionsValidationError
1 parent 7d0a442 commit 8ecae31

File tree

2 files changed

+6
-38
lines changed

2 files changed

+6
-38
lines changed

lib/WebpackOptionsValidationError.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ class WebpackOptionsValidationError extends Error {
181181
return `${dataPath} should not be empty.`;
182182
else
183183
return `${dataPath} ${err.message}`;
184+
} else if(err.keyword === "absolutePath") {
185+
return `${dataPath}: ${err.message}`;
184186
} else {
185187
// eslint-disable-line no-fallthrough
186188
return `${dataPath} ${err.message} (${JSON.stringify(err, 0, 2)}).\n${getSchemaPartText(err.parentSchema)}`;

test/Validation.test.js

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -184,25 +184,8 @@ describe("Validation", function() {
184184
}
185185
},
186186
message: [
187-
" - configuration.output.filename A non-absolut path is expected. However the provided value \"/bar\" is an absolute path!",
188-
" ({",
189-
" \"keyword\": \"absolutePath\",",
190-
" \"params\": {",
191-
" \"absolutePath\": \"/bar\"",
192-
" },",
193-
" \"message\": \"A non-absolut path is expected. However the provided value \\\"/bar\\\" is an absolute path!\\n\",",
194-
" \"parentSchema\": {",
195-
" \"description\": \"Specifies the name of each output file on disk. You must **not** specify an absolute path here! The `output.path` option determines the location on disk the files are written to, filename is used solely for naming the individual files.\",",
196-
" \"type\": \"string\",",
197-
" \"absolutePath\": false",
198-
" },",
199-
" \"dataPath\": \".output.filename\",",
200-
" \"schemaPath\": \"#/definitions/output/properties/filename/absolutePath\",",
201-
" \"schema\": false,",
202-
" \"data\": \"/bar\"",
203-
" }).",
204-
" string",
205-
" Specifies the name of each output file on disk. You must **not** specify an absolute path here! The `output.path` option determines the location on disk the files are written to, filename is used solely for naming the individual files."
187+
" - configuration.output.filename: A non-absolut path is expected. However the provided value \"/bar\" is an absolute path!",
188+
"",
206189
]
207190
}, {
208191
name: "absolute path",
@@ -214,25 +197,8 @@ describe("Validation", function() {
214197
context: "baz"
215198
},
216199
message: [
217-
" - configuration.context The provided value \"baz\" is not an absolute path!",
218-
" ({",
219-
" \"keyword\": \"absolutePath\",",
220-
" \"params\": {",
221-
" \"absolutePath\": \"baz\"",
222-
" },",
223-
" \"message\": \"The provided value \\\"baz\\\" is not an absolute path!\\n\",",
224-
" \"parentSchema\": {",
225-
" \"description\": \"The base directory (absolute path!) for resolving the `entry` option. If `output.pathinfo` is set, the included pathinfo is shortened to this directory.\",",
226-
" \"type\": \"string\",",
227-
" \"absolutePath\": true",
228-
" },",
229-
" \"dataPath\": \".context\",",
230-
" \"schemaPath\": \"#/properties/context/absolutePath\",",
231-
" \"schema\": true,",
232-
" \"data\": \"baz\"",
233-
" }).",
234-
" string",
235-
" The base directory (absolute path!) for resolving the `entry` option. If `output.pathinfo` is set, the included pathinfo is shortened to this directory."
200+
" - configuration.context: The provided value \"baz\" is not an absolute path!",
201+
"",
236202
]
237203
}];
238204
testCases.forEach(function(testCase) {

0 commit comments

Comments
 (0)