Skip to content

Commit 58dcc0f

Browse files
authored
Merge pull request #41 from neil-forks/handle-symlinks
fix: handle symlinks properly in file enumeration
2 parents 1771e49 + 8799cb9 commit 58dcc0f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/cli/util/files.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,18 @@ function enumerateFilesWorker(results: string[], dir: string, opts: EnumerateFil
5252

5353
if (entry.isDirectory()) {
5454
enumerateFilesWorker(results, fullpath, opts);
55+
} else if (entry.isSymbolicLink()) {
56+
try {
57+
const stats = fs.statSync(fullpath);
58+
if (stats.isDirectory()) {
59+
enumerateFilesWorker(results, fullpath, opts);
60+
} else if (stats.isFile()) {
61+
results.push(fullpath);
62+
}
63+
} catch (err) {
64+
// Skip broken symlinks
65+
continue;
66+
}
5567
} else {
5668
results.push(fullpath);
5769
}

0 commit comments

Comments
 (0)