Skip to content

Commit

Permalink
Fixed FileSystem.exists return false for non-ENOENT errors (+*Sync)
Browse files Browse the repository at this point in the history
Formatting
  • Loading branch information
james-pre committed May 19, 2024
1 parent cf8cbca commit aaa3fb7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/emulation/promises.ts
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ async function _open(path: fs.PathLike, _flag: fs.OpenMode, _mode: fs.Mode = 0o6
}
} catch (_) {
const original = _ as ErrnoError;
if(original.code != 'ENOENT') {
if (original.code != 'ENOENT') {
throw original;
}
try {
Expand Down
4 changes: 2 additions & 2 deletions src/emulation/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ function _openSync(_path: fs.PathLike, _flag: fs.OpenMode, _mode?: fs.Mode | nul
stats = wrap('statSync', resolveSymlinks, path, cred);
} catch (_) {
const original = _ as ErrnoError;
if(original.code != 'ENOENT') {
if (original.code != 'ENOENT') {
throw original;
}
try {
Expand All @@ -151,7 +151,7 @@ function _openSync(_path: fs.PathLike, _flag: fs.OpenMode, _mode?: fs.Mode | nul
}
} catch (_) {
const ex = _ as ErrnoError;
ex.stack += '\n<original>\n'
ex.stack += '\n<original>\n';
ex.stack += (original as Error).stack;
throw ex;
}
Expand Down
4 changes: 2 additions & 2 deletions src/filesystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export abstract class FileSystem {
await this.stat(path, cred);
return true;
} catch (e) {
return false;
return (e as ErrnoError).code != 'ENOENT';
}
}

Expand All @@ -184,7 +184,7 @@ export abstract class FileSystem {
this.statSync(path, cred);
return true;
} catch (e) {
return false;
return (e as ErrnoError).code != 'ENOENT';
}
}

Expand Down

0 comments on commit aaa3fb7

Please sign in to comment.