From a4c2b2bc1d9059c97ff81bcfc20c0949aacc5d2f Mon Sep 17 00:00:00 2001 From: dmail Date: Sun, 24 Nov 2024 22:31:28 +0100 Subject: [PATCH] restore somthing --- .../filesystem/spy_filesystem_calls.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/packages/independent/snapshot/src/side_effects/filesystem/spy_filesystem_calls.js b/packages/independent/snapshot/src/side_effects/filesystem/spy_filesystem_calls.js index 09283e74cc..1409b1fefe 100644 --- a/packages/independent/snapshot/src/side_effects/filesystem/spy_filesystem_calls.js +++ b/packages/independent/snapshot/src/side_effects/filesystem/spy_filesystem_calls.js @@ -5,14 +5,17 @@ import { comparePathnames, - readEntryStatSync, removeDirectorySync, removeFileSync, writeFileSync, } from "@jsenv/filesystem"; import { URL_META } from "@jsenv/url-meta"; -import { ensurePathnameTrailingSlash, yieldAncestorUrls } from "@jsenv/urls"; -import { readdirSync, readFileSync } from "node:fs"; +import { + ensurePathnameTrailingSlash, + urlToFileSystemPath, + yieldAncestorUrls, +} from "@jsenv/urls"; +import { readdirSync, readFileSync, statSync } from "node:fs"; import { pathToFileURL } from "node:url"; import { disableHooksWhileCalling, @@ -178,7 +181,9 @@ export const spyFilesystemCalls = ( if (!stateBefore.found && recursive) { const ancestorNotFoundArray = []; for (const ancestorUrl of yieldAncestorUrls(directoryUrl)) { - const ancestorState = getDirectoryState(new URL(ancestorUrl)); + const ancestorState = getDirectoryState( + urlToFileSystemPath(new URL(ancestorUrl)), + ); if (ancestorState.found) { break; } @@ -349,7 +354,7 @@ const getFileState = (filePath) => { const fileUrl = pathToFileURL(filePath); try { const fileBuffer = readFileSync(fileUrl); - const { mtimeMs } = readEntryStatSync(fileUrl); + const { mtimeMs } = statSync(filePath); return { url: String(fileUrl), found: true, @@ -369,7 +374,7 @@ const getFileState = (filePath) => { const getDirectoryState = (directory) => { try { - readEntryStatSync(directory); + statSync(directory); return { found: true, };