Skip to content

Commit 4ded364

Browse files
fix(ext/node): validate fs.watch boolean options (#33627)
Enables `parallel/test-fs-watch-recursive-validate.js`. Co-authored-by: Nathan Whitaker <nathan@deno.com>
1 parent 0c476ad commit 4ded364

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

ext/node/polyfills/fs.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3270,6 +3270,14 @@ function watch(
32703270
// deno-lint-ignore prefer-primordials
32713271
const watchPath = getValidatedPath(filename).toString();
32723272

3273+
// Match Node: validate non-boolean `recursive`/`persistent` up front.
3274+
// https://github.com/nodejs/node/blob/main/lib/internal/fs/recursive_watch.js
3275+
if (options != null && options.recursive != null) {
3276+
validateBoolean(options.recursive, "options.recursive");
3277+
}
3278+
if (options != null && options.persistent != null) {
3279+
validateBoolean(options.persistent, "options.persistent");
3280+
}
32733281
const recursive = options?.recursive || false;
32743282
validateIgnoreOption(options?.ignore, "options.ignore");
32753283
const ignoreMatcher = createIgnoreMatcher(options?.ignore);

tests/node_compat/config.jsonc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,6 +1208,7 @@
12081208
"parallel/test-fs-watch-recursive-add-folder.js": {},
12091209
"parallel/test-fs-watch-recursive-delete.js": {},
12101210
"parallel/test-fs-watch-recursive-linux-parallel-remove.js": {},
1211+
"parallel/test-fs-watch-recursive-validate.js": {},
12111212
"parallel/test-fs-watch-ref-unref.js": {},
12121213
"parallel/test-fs-watch-stop-async.js": {},
12131214
"parallel/test-fs-watch-stop-sync.js": {},

0 commit comments

Comments
 (0)