Skip to content

Commit

Permalink
fix: output description for static options (#3246)
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 authored May 5, 2021
1 parent e2b43b8 commit 6e0e653
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/options.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"properties": {
"directory": {
"type": "string",
"minLength": 1
"minLength": 1,
"description": "Directory for static contents."
},
"staticOptions": {
"type": "object",
Expand Down Expand Up @@ -48,9 +49,11 @@
"type": "boolean"
},
{
"type": "object"
"type": "object",
"description": "options for watch, you can find at https://github.com/paulmillr/chokidar"
}
]
],
"description": "Watch for files in static content directory."
}
}
},
Expand Down
22 changes: 22 additions & 0 deletions test/__snapshots__/validate-options.test.js.snap.webpack4
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,12 @@ exports[`options validate should throw an error on the "static" option with '' v
- configuration.static should be an non-empty string."
`;

exports[`options validate should throw an error on the "static" option with '{"directory":false}' value 1`] = `
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
- configuration.static.directory should be a non-empty string.
-> Directory for static contents."
`;

exports[`options validate should throw an error on the "static" option with '{"publicPath":false}' value 1`] = `
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
- configuration.static should be one of these:
Expand Down Expand Up @@ -338,6 +344,22 @@ exports[`options validate should throw an error on the "static" option with '{"s
object { … }"
`;

exports[`options validate should throw an error on the "static" option with '{"watch":10}' value 1`] = `
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
- configuration.static should be one of these:
boolean | non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? } | [non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }, ...] (should not have fewer than 1 item)
-> It is possible to configure advanced options for serving static files from directory. See the Express documentation for the possible options. https://webpack.js.org/configuration/dev-server/#devserverstatic
Details:
* configuration.static.watch should be one of these:
boolean | object { … }
-> Watch for files in static content directory.
Details:
* configuration.static.watch should be a boolean.
* configuration.static.watch should be an object:
object { … }
-> options for watch, you can find at https://github.com/paulmillr/chokidar"
`;

exports[`options validate should throw an error on the "static" option with '0' value 1`] = `
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
- configuration.static should be one of these:
Expand Down
22 changes: 22 additions & 0 deletions test/__snapshots__/validate-options.test.js.snap.webpack5
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,12 @@ exports[`options validate should throw an error on the "static" option with '' v
- configuration.static should be an non-empty string."
`;

exports[`options validate should throw an error on the "static" option with '{"directory":false}' value 1`] = `
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
- configuration.static.directory should be a non-empty string.
-> Directory for static contents."
`;

exports[`options validate should throw an error on the "static" option with '{"publicPath":false}' value 1`] = `
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
- configuration.static should be one of these:
Expand Down Expand Up @@ -338,6 +344,22 @@ exports[`options validate should throw an error on the "static" option with '{"s
object { … }"
`;

exports[`options validate should throw an error on the "static" option with '{"watch":10}' value 1`] = `
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
- configuration.static should be one of these:
boolean | non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? } | [non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }, ...] (should not have fewer than 1 item)
-> It is possible to configure advanced options for serving static files from directory. See the Express documentation for the possible options. https://webpack.js.org/configuration/dev-server/#devserverstatic
Details:
* configuration.static.watch should be one of these:
boolean | object { … }
-> Watch for files in static content directory.
Details:
* configuration.static.watch should be a boolean.
* configuration.static.watch should be an object:
object { … }
-> options for watch, you can find at https://github.com/paulmillr/chokidar"
`;

exports[`options validate should throw an error on the "static" option with '0' value 1`] = `
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
- configuration.static should be one of these:
Expand Down
6 changes: 6 additions & 0 deletions test/validate-options.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,12 @@ const tests = {
{
serveIndex: 'true',
},
{
directory: false,
},
{
watch: 10,
},
],
},
transportMode: {
Expand Down

0 comments on commit 6e0e653

Please sign in to comment.