Skip to content

Commit 3f12a95

Browse files
committed
vfs: remove internalModuleStat from provider base class
Move the internalModuleStat logic into VirtualFileSystem where it is used internally, instead of exposing it on the VFSProvider base class. The method now uses statSync directly rather than delegating to the provider.
1 parent 085a542 commit 3f12a95

File tree

2 files changed

+5
-20
lines changed

2 files changed

+5
-20
lines changed

lib/internal/vfs/file_system.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,8 +609,11 @@ class VirtualFileSystem {
609609
*/
610610
internalModuleStat(filePath) {
611611
try {
612-
const providerPath = this.#toProviderPath(filePath);
613-
return this[kProvider].internalModuleStat(providerPath);
612+
const stats = this.statSync(filePath);
613+
if (stats.isDirectory()) {
614+
return 1;
615+
}
616+
return 0;
614617
} catch {
615618
return -2;
616619
}

lib/internal/vfs/provider.js

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -387,24 +387,6 @@ class VirtualProvider {
387387
this.writeFileSync(dest, content);
388388
}
389389

390-
/**
391-
* Returns the stat result code for module resolution.
392-
* Used by Module._stat override.
393-
* @param {string} path The path to check
394-
* @returns {number} 0 for file, 1 for directory, -2 for not found
395-
*/
396-
internalModuleStat(path) {
397-
try {
398-
const stats = this.statSync(path);
399-
if (stats.isDirectory()) {
400-
return 1;
401-
}
402-
return 0;
403-
} catch {
404-
return -2; // ENOENT
405-
}
406-
}
407-
408390
/**
409391
* Gets the real path by resolving symlinks.
410392
* @param {string} path The path

0 commit comments

Comments
 (0)