Change the contents of the file every 100 milliseconds until the watcher
notices the change. This is already done in the callback based version
of the test (`test-fs-watch.js`).
Fixes: https://github.com/nodejs/node/issues/37637
PR-URL: https://github.com/nodejs/node/pull/40863
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Nitzan Uziely <linkgoron@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Make changes so that tests will pass when the comma-dangle settings
applied to the rest of the code base are also applied to tests.
PR-URL: https://github.com/nodejs/node/pull/37930
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Derek Lewis <DerekNonGeneric@inf.is>
An alternative to `fs.watch()` that returns an `AsyncIterator`
```js
const { watch } = require('fs/promises');
(async () => {
const ac = new AbortController();
const { signal } = ac;
setTimeout(() => ac.abort(), 10000);
const watcher = watch('file.txt', { signal });
for await (const { eventType, filename } of watcher) {
console.log(eventType, filename);
}
})()
```
Signed-off-by: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/37179
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>