From 9cafcfb3cbb227079cb0e803276adac307ef50d8 Mon Sep 17 00:00:00 2001 From: Herrington Darkholme Date: Thu, 4 Feb 2016 14:26:59 +0800 Subject: [PATCH] ignore hidden file by default --- src/compiler/commandLineParser.ts | 5 +++++ src/compiler/core.ts | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 733e3158593df..83e808c46ce5c 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -523,6 +523,11 @@ namespace ts { for (const extension of supportedExtensions) { const filesInDirWithExtension = host.readDirectory(basePath, extension, exclude); for (const fileName of filesInDirWithExtension) { + // skip hidden file on unixy platform + if (isHiddenFile(fileName)) { + continue; + } + // .ts extension would read the .d.ts extension files too but since .d.ts is lower priority extension, // lets pick them when its turn comes up if (extension === ".ts" && fileExtensionIs(fileName, ".d.ts")) { diff --git a/src/compiler/core.ts b/src/compiler/core.ts index cfdcb2b930c63..dee3118ccfed6 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -769,6 +769,10 @@ namespace ts { return pathLen > extLen && path.substr(pathLen - extLen, extLen) === extension; } + export function isHiddenFile(path: string): boolean { + return getBaseFileName(path)[0] === "."; + } + /** * List of supported extensions in order of file resolution precedence. */ @@ -781,7 +785,7 @@ namespace ts { } export function isSupportedSourceFileName(fileName: string, compilerOptions?: CompilerOptions) { - if (!fileName) { return false; } + if (!fileName || isHiddenFile(fileName)) { return false; } for (const extension of getSupportedExtensions(compilerOptions)) { if (fileExtensionIs(fileName, extension)) {