From d0545ffee85bf35accc839777065d85d032f51a7 Mon Sep 17 00:00:00 2001 From: zhengbli Date: Thu, 24 Mar 2016 14:16:38 -0700 Subject: [PATCH] Explicitly exclude . and .. for fs.readdirSync --- src/compiler/sys.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 0bb87cc5a40..3f243b41d02 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -495,7 +495,9 @@ namespace ts { visitDirectory(path); return result; function visitDirectory(path: string) { - const files = _fs.readdirSync(path || ".").sort(); + // This filtering is necessary because on some file system node fails to exclude + // "." and "..". See https://github.com/nodejs/node/issues/4002 + const files = filter(_fs.readdirSync(path || "."), f => f !== "." && f !== "..").sort(); const directories: string[] = []; for (const current of files) { const name = combinePaths(path, current);