Merge pull request #8484 from zhengbli/ignoreHiddenFiles
ignore dotted files and folders
This commit is contained in:
commit
d11ee08170
2 changed files with 44 additions and 4 deletions
|
@ -652,6 +652,9 @@ namespace ts {
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Skip over any minified JavaScript files (ending in ".min.js")
|
||||||
|
// Skip over dotted files and folders as well
|
||||||
|
const IgnoreFileNamePattern = /(\.min\.js$)|([\\/]\.[\w.])/;
|
||||||
/**
|
/**
|
||||||
* Parse the contents of a config file (tsconfig.json).
|
* Parse the contents of a config file (tsconfig.json).
|
||||||
* @param json The contents of the config file to parse
|
* @param json The contents of the config file to parse
|
||||||
|
@ -715,8 +718,7 @@ namespace ts {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip over any minified JavaScript files (ending in ".min.js")
|
if (IgnoreFileNamePattern.test(fileName)) {
|
||||||
if (/\.min\.js$/.test(fileName)) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,34 @@ namespace ts {
|
||||||
assert.isTrue(undefined !== parsedCommand.errors);
|
assert.isTrue(undefined !== parsedCommand.errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function assertParseFileList(jsonText: string, configFileName: string, basePath: string, allFileList: string[], expectedFileList: string[]) {
|
||||||
|
const json = JSON.parse(jsonText);
|
||||||
|
const host: ParseConfigHost = { readDirectory: mockReadDirectory };
|
||||||
|
const parsed = ts.parseJsonConfigFileContent(json, host, basePath, /*existingOptions*/ undefined, configFileName);
|
||||||
|
assert.isTrue(arrayIsEqualTo(parsed.fileNames.sort(), expectedFileList.sort()));
|
||||||
|
|
||||||
|
function mockReadDirectory(rootDir: string, extension: string, exclude: string[]): string[] {
|
||||||
|
const result: string[] = [];
|
||||||
|
const fullExcludeDirectories = ts.map(exclude, directory => combinePaths(rootDir, directory));
|
||||||
|
for (const file of allFileList) {
|
||||||
|
let shouldExclude = false;
|
||||||
|
for (const fullExcludeDirectorie of fullExcludeDirectories) {
|
||||||
|
if (file.indexOf(fullExcludeDirectorie) >= 0) {
|
||||||
|
shouldExclude = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (shouldExclude) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (fileExtensionIs(file, extension)) {
|
||||||
|
result.push(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
it("returns empty config for file with only whitespaces", () => {
|
it("returns empty config for file with only whitespaces", () => {
|
||||||
assertParseResult("", { config : {} });
|
assertParseResult("", { config : {} });
|
||||||
assertParseResult(" ", { config : {} });
|
assertParseResult(" ", { config : {} });
|
||||||
|
@ -120,5 +148,15 @@ namespace ts {
|
||||||
]
|
]
|
||||||
}`);
|
}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("ignore dotted files and folders", () => {
|
||||||
|
assertParseFileList(
|
||||||
|
`{}`,
|
||||||
|
"tsconfig.json",
|
||||||
|
"/apath",
|
||||||
|
["/apath/test.ts", "/apath/.git/a.ts", "/apath/.b.ts", "/apath/..c.ts"],
|
||||||
|
["/apath/test.ts"]
|
||||||
|
)
|
||||||
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue