Skip to content

Commit

Permalink
watch: clarify that the fileName parameter can be null
Browse files Browse the repository at this point in the history
Add a comment to clarify that the `fileName` parameter can be `null` if
the file name cannot be determined.

PR-URL: #51305
Reviewed-By: Vinícius Lourenço Claro Cardoso <[email protected]>
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
  • Loading branch information
lpinca authored Dec 30, 2023
1 parent 338a5be commit 8bb3027
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/internal/watch_mode/files_watcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,11 @@ class FilesWatcher extends EventEmitter {
return;
}
const watcher = watch(path, { recursive, signal: this.#signal });
watcher.on('change', (eventType, fileName) => this
.#onChange(recursive ? resolve(path, fileName ?? '') : path));
watcher.on('change', (eventType, fileName) => {
// `fileName` can be `null` if it cannot be determined. See
// https://github.com/nodejs/node/pull/49891#issuecomment-1744673430.
this.#onChange(recursive ? resolve(path, fileName ?? '') : path);
});
this.#watchers.set(path, { handle: watcher, recursive });
if (recursive) {
this.#removeWatchedChildren(path);
Expand Down

0 comments on commit 8bb3027

Please sign in to comment.