mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
docs(watch): rename filename to relativePath in recursive example (#23990)
When using `fs.watch()` with `recursive: true`, the callback receives a
relative path from the watched directory (e.g., `'subdir/file.txt'`),
not just a filename.
Renaming the parameter from `filename` to `relativePath` makes this
behavior immediately clear to developers.
**Before:**
```ts
(event, filename) => {
console.log(`Detected ${event} in ${filename}`);
}
```
**After:**
```ts
(event, relativePath) => {
console.log(`Detected ${event} in ${relativePath}`);
}
```
This is a documentation-only change that improves clarity without
altering any functionality.
Co-authored-by: Braden Wong <git@bradenwong.com>
This commit is contained in:
@@ -24,8 +24,8 @@ import { watch } from "fs";
|
||||
const watcher = watch(
|
||||
import.meta.dir,
|
||||
{ recursive: true },
|
||||
(event, filename) => {
|
||||
console.log(`Detected ${event} in ${filename}`);
|
||||
(event, relativePath) => {
|
||||
console.log(`Detected ${event} in ${relativePath}`);
|
||||
},
|
||||
);
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user