1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-24 08:09:08 -05:00

fix(ext/node): pass normalized watchFile handler to StatWatcher (#22940)

Fixes https://github.com/denoland/deno/issues/22939
This commit is contained in:
Divy Srivastava 2024-03-15 21:14:47 -07:00 committed by GitHub
parent ab67b4c645
commit 9c5ddf7c69
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 2 deletions

View file

@ -211,7 +211,7 @@ export function watchFile(
statWatchers.set(watchPath, stat);
}
stat.addListener("change", listener!);
stat.addListener("change", handler);
return stat;
}

View file

@ -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) {
@ -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);
},
});