docs(watch): use relativePath parameter name in recursive example (#24716)

This updates the documentation for `fs.watch()` to use `relativePath`
instead of `filename` in the recursive example, following the same
convention from PR #23990.

When `recursive: true` is set on `fs.watch()`, the callback receives a
relative path to the changed file rather than just a simple filename.
Using `relativePath` as the parameter name makes this distinction
clearer to users.

**Related to:** https://github.com/oven-sh/bun/pull/23990

Co-authored-by: Michael H <git@riskymh.dev>
This commit is contained in:
Braden Wong
2025-11-14 06:10:35 -08:00
committed by GitHub
parent c3c91442ac
commit 65a215bb4e

View File

@@ -23,8 +23,8 @@ To listen to changes in subdirectories, pass the `recursive: true` option to `fs
```ts ```ts
import { watch } from "fs"; import { watch } from "fs";
const watcher = watch(import.meta.dir, { recursive: true }, (event, filename) => { const watcher = watch(import.meta.dir, { recursive: true }, (event, relativePath) => {
console.log(`Detected ${event} in ${filename}`); console.log(`Detected ${event} in ${relativePath}`);
}); });
``` ```