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").
This commit is contained in:
Syam Gadde
2025-11-11 09:41:55 -05:00
committed by Kirill Cherkashin
parent 68f5ceeb46
commit 1628125bcb
@@ -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;
}
}