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 660659f
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 660659f

Please sign in to comment.