Skip to content

Commit

Permalink
fix(ext/node): pass normalized watchFile handler to StatWatcher (#22940)
Browse files Browse the repository at this point in the history
Fixes #22939
  • Loading branch information
littledivy authored Mar 16, 2024
1 parent ab67b4c commit 9c5ddf7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ext/node/polyfills/_fs/_fs_watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export function watchFile(
statWatchers.set(watchPath, stat);
}

stat.addListener("change", listener!);
stat.addListener("change", handler);
return stat;
}

Expand Down
15 changes: 14 additions & 1 deletion tests/unit_node/_fs/_fs_watch_test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { watch } from "node:fs";
import { unwatchFile, watch, watchFile } from "node:fs";
import { assertEquals } from "@std/assert/mod.ts";

function wait(time: number) {
Expand All @@ -25,3 +25,16 @@ Deno.test({
assertEquals(result.length >= 1, true);
},
});

Deno.test({
name: "watching a file with options",
async fn() {
const file = Deno.makeTempFileSync();
watchFile(
file,
() => {},
);
await wait(100);
unwatchFile(file);
},
});

0 comments on commit 9c5ddf7

Please sign in to comment.