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.
  • Loading branch information
lpinca committed Dec 28, 2023
1 parent 9db4bf4 commit fc3bdab
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` on Windows. 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 fc3bdab

Please sign in to comment.