MCPcopy Index your code
hub / github.com/nodejs/node / doWatch

Function doWatch

test/parallel/test-fs-watch-recursive-sync-write.js:28–40  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

26}, common.platformTimeout(30_000));
27
28function doWatch() {
29 const watcher = watch(tmpDir, { recursive: true }, common.mustCall((eventType, _filename) => {
30 clearTimeout(keepalive);
31 watcher.close();
32 assert.strictEqual(eventType, 'rename');
33 assert.strictEqual(join(tmpDir, _filename), filename);
34 }));
35
36 // Do the write with a delay to ensure that the OS is ready to notify us.
37 setTimeout(() => {
38 writeFileSync(filename, 'foobar2');
39 }, common.platformTimeout(200));
40}
41
42if (common.isMacOS) {
43 // On macOS delay watcher start to avoid leaking previous events.

Calls 6

writeFileSyncFunction · 0.85
closeMethod · 0.65
watchFunction · 0.50
clearTimeoutFunction · 0.50
joinFunction · 0.50
setTimeoutFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…