Skip to content

Commit d0545ff

Browse files
committed
Explicitly exclude . and .. for fs.readdirSync
1 parent ec8eeff commit d0545ff

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/compiler/sys.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,9 @@ namespace ts {
495495
visitDirectory(path);
496496
return result;
497497
function visitDirectory(path: string) {
498-
const files = _fs.readdirSync(path || ".").sort();
498+
// This filtering is necessary because on some file system node fails to exclude
499+
// "." and "..". See https://github.com/nodejs/node/issues/4002
500+
const files = filter(<string[]>_fs.readdirSync(path || "."), f => f !== "." && f !== "..").sort();
499501
const directories: string[] = [];
500502
for (const current of files) {
501503
const name = combinePaths(path, current);

0 commit comments

Comments
 (0)