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 and RafaelGSS committed Jan 2, 2024
1 parent 416b4f8 commit 867b484
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 867b484

Please sign in to comment.