Skip to content

Commit 7c8852c

Browse files
committed
fix: add description for watchFiles options
1 parent c5b9c7e commit 7c8852c

File tree

4 files changed

+62
-2
lines changed

4 files changed

+62
-2
lines changed

lib/options.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -984,10 +984,13 @@
984984
"type": "string",
985985
"minLength": 1
986986
}
987-
]
987+
],
988+
"description": "Path(s) of globs/directories/files to watch for file changes."
988989
},
989990
"options": {
990991
"type": "object",
992+
"description": "Configure advanced options for watching. See the chokidar documentation for the possible options.",
993+
"link": "https://github.com/paulmillr/chokidar#api",
991994
"additionalProperties": true
992995
}
993996
},

test/__snapshots__/validate-options.test.js.snap.webpack4

+24
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,30 @@ exports[`options validate should throw an error on the "static" option with 'nul
789789
object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }"
790790
`;
791791

792+
exports[`options validate should throw an error on the "watchFiles" option with '{"options":false}' value 1`] = `
793+
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
794+
- options.watchFiles.options should be an object:
795+
object { … }
796+
-> Configure advanced options for watching. See the chokidar documentation for the possible options.
797+
-> Read more at https://github.com/paulmillr/chokidar#api"
798+
`;
799+
800+
exports[`options validate should throw an error on the "watchFiles" option with '{"paths":false}' value 1`] = `
801+
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
802+
- options.watchFiles should be one of these:
803+
[non-empty string | object { paths?, options? }, ...] | non-empty string | object { paths?, options? }
804+
-> Allows to configure list of globs/directories/files to watch for file changes.
805+
-> Read more at https://webpack.js.org/configuration/dev-server/#devserverwatchfiles
806+
Details:
807+
* options.watchFiles.paths should be one of these:
808+
[non-empty string, ...] | non-empty string
809+
-> Path(s) of globs/directories/files to watch for file changes.
810+
Details:
811+
* options.watchFiles.paths should be an array:
812+
[non-empty string, ...]
813+
* options.watchFiles.paths should be a non-empty string."
814+
`;
815+
792816
exports[`options validate should throw an error on the "watchFiles" option with '123' value 1`] = `
793817
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
794818
- options.watchFiles should be one of these:

test/__snapshots__/validate-options.test.js.snap.webpack5

+24
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,30 @@ exports[`options validate should throw an error on the "static" option with 'nul
789789
object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }"
790790
`;
791791

792+
exports[`options validate should throw an error on the "watchFiles" option with '{"options":false}' value 1`] = `
793+
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
794+
- options.watchFiles.options should be an object:
795+
object { … }
796+
-> Configure advanced options for watching. See the chokidar documentation for the possible options.
797+
-> Read more at https://github.com/paulmillr/chokidar#api"
798+
`;
799+
800+
exports[`options validate should throw an error on the "watchFiles" option with '{"paths":false}' value 1`] = `
801+
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
802+
- options.watchFiles should be one of these:
803+
[non-empty string | object { paths?, options? }, ...] | non-empty string | object { paths?, options? }
804+
-> Allows to configure list of globs/directories/files to watch for file changes.
805+
-> Read more at https://webpack.js.org/configuration/dev-server/#devserverwatchfiles
806+
Details:
807+
* options.watchFiles.paths should be one of these:
808+
[non-empty string, ...] | non-empty string
809+
-> Path(s) of globs/directories/files to watch for file changes.
810+
Details:
811+
* options.watchFiles.paths should be an array:
812+
[non-empty string, ...]
813+
* options.watchFiles.paths should be a non-empty string."
814+
`;
815+
792816
exports[`options validate should throw an error on the "watchFiles" option with '123' value 1`] = `
793817
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
794818
- options.watchFiles should be one of these:

test/validate-options.test.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,16 @@ const tests = {
548548
{ paths: ["dir"], options: { usePolling: true } },
549549
[{ paths: ["one-dir"] }, "two-dir"],
550550
],
551-
failure: [false, 123],
551+
failure: [
552+
false,
553+
123,
554+
{
555+
paths: false,
556+
},
557+
{
558+
options: false,
559+
},
560+
],
552561
},
553562
};
554563

0 commit comments

Comments
 (0)