fix(compiler-cli): ignore non-existent files

Ignore files that fail fs.exists() rather than throw ENOENT.  Some applications deliberately create "broken" symbolic links that are not relevant to compilation (e.g. emacs lock files that link to owner "user@host").

(cherry picked from commit 1628125bcb)
This commit is contained in:
Syam Gadde 2025-11-11 09:41:55 -05:00 committed by kirjs
parent 1cdcd5a947
commit bc34083d34

View file

@ -90,10 +90,18 @@ export function createFileSystemTsReadDirectoryFn(
const directories: string[] = [];
for (const child of children) {
if (fs.stat(fs.join(resolvedPath, child))?.isDirectory()) {
directories.push(child);
} else {
files.push(child);
try {
if (fs.stat(fs.join(resolvedPath, child))?.isDirectory()) {
directories.push(child);
} else {
files.push(child);
}
} catch (error) {
if (error instanceof Error && error.message.includes('ENOENT')) {
// may be a dangling link or other file system error, ignore
continue;
}
throw error;
}
}