Explicitly exclude . and .. for fs.readdirSync

This commit is contained in:
zhengbli 2016-03-24 14:16:38 -07:00
parent ec8eefffb0
commit d0545ffee8

View file

@ -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(<string[]>_fs.readdirSync(path || "."), f => f !== "." && f !== "..").sort();
const directories: string[] = [];
for (const current of files) {
const name = combinePaths(path, current);