Skip to content

fix: output description for static options #3246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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