Skip to content

Commit bc34083

Browse files
SyamGaddekirjs
authored andcommitted
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 1628125)
1 parent 1cdcd5a commit bc34083

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

packages/compiler-cli/src/ngtsc/file_system/src/ts_read_directory.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,18 @@ export function createFileSystemTsReadDirectoryFn(
9090
const directories: string[] = [];
9191

9292
for (const child of children) {
93-
if (fs.stat(fs.join(resolvedPath, child))?.isDirectory()) {
94-
directories.push(child);
95-
} else {
96-
files.push(child);
93+
try {
94+
if (fs.stat(fs.join(resolvedPath, child))?.isDirectory()) {
95+
directories.push(child);
96+
} else {
97+
files.push(child);
98+
}
99+
} catch (error) {
100+
if (error instanceof Error && error.message.includes('ENOENT')) {
101+
// may be a dangling link or other file system error, ignore
102+
continue;
103+
}
104+
throw error;
97105
}
98106
}
99107

0 commit comments

Comments
 (0)