From 9d6da1036d80a29862f6bdfb51e6f51eee235c35 Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Wed, 7 Aug 2024 18:15:57 +0200 Subject: fix: `rename` watch event missing (#24893) This PR ensures that we forward a `rename` event in our file watcher. The rust lib we use combines that with the `modify` event. This fixes a compatibility issue with Node too, which sends the `rename` event as well. Fixes https://github.com/denoland/deno/issues/24880 --- tests/unit/fs_events_test.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests') diff --git a/tests/unit/fs_events_test.ts b/tests/unit/fs_events_test.ts index 4f7cdc4d5..3a867f07e 100644 --- a/tests/unit/fs_events_test.ts +++ b/tests/unit/fs_events_test.ts @@ -70,6 +70,26 @@ Deno.test( }, ); +Deno.test( + { permissions: { read: true, write: true } }, + async function watchFsRename() { + const testDir = await makeTempDir(); + const watcher = Deno.watchFs(testDir); + async function waitForRename() { + for await (const event of watcher) { + if (event.kind === "rename") { + break; + } + } + } + const eventPromise = waitForRename(); + const file = testDir + "/file.txt"; + await Deno.writeTextFile(file, "hello"); + await Deno.rename(file, testDir + "/file2.txt"); + await eventPromise; + }, +); + // TODO(kt3k): This test is for the backward compatibility of `.return` method. // This should be removed at 2.0 Deno.test( -- cgit v1.2.3