Fixing shim and normalizing paths

This commit is contained in:
Richard Knoll
2016-08-04 11:10:00 -07:00
parent 293ca60ffd
commit ca288231f7
2 changed files with 14 additions and 6 deletions

View File

@@ -4594,6 +4594,7 @@ namespace ts {
// Enumerate the available files
const files = host.readDirectory(baseDirectory, extensions, /*exclude*/undefined, /*include*/["./*"]);
forEach(files, filePath => {
filePath = normalizePath(filePath);
if (exclude && comparePaths(filePath, exclude, scriptPath, ignoreCase) === Comparison.EqualTo) {
return false;
}
@@ -4614,7 +4615,7 @@ namespace ts {
if (host.getDirectories) {
const directories = host.getDirectories(baseDirectory);
forEach(directories, d => {
const directoryName = getBaseFileName(removeTrailingDirectorySeparator(d));
const directoryName = getBaseFileName(normalizePath(d));
result.push({
name: ensureTrailingDirectorySeparator(directoryName),
@@ -4755,6 +4756,7 @@ namespace ts {
const nestedFiles = host.readDirectory(visibleModule.moduleDir, supportedTypeScriptExtensions, /*exclude*/undefined, /*include*/["./*"]);
forEach(nestedFiles, (f) => {
f = normalizePath(f);
const nestedModule = removeFileExtension(getBaseFileName(f));
nonRelativeModules.push(nestedModule);
});
@@ -4850,6 +4852,7 @@ namespace ts {
function getCompletionEntriesFromDirectories(host: LanguageServiceHost, options: CompilerOptions, directory: string, result: ImportCompletionEntry[]) {
if (host.getDirectories && directoryProbablyExists(directory, host)) {
forEach(host.getDirectories(directory), typeDirectory => {
typeDirectory = normalizePath(typeDirectory);
result.push(createCompletionEntryForModule(getBaseFileName(typeDirectory), ScriptElementKind.externalModuleName));
});
}

View File

@@ -67,7 +67,7 @@ namespace ts {
getProjectVersion?(): string;
useCaseSensitiveFileNames?(): boolean;
readDirectory(path: string, extensions?: string, exclude?: string, include?: string): string;
readDirectory(rootDir: string, extension: string, basePaths?: string, excludeEx?: string, includeFileEx?: string, includeDirEx?: string, depth?: number): string;
readFile(path: string, encoding?: string): string;
resolvePath(path: string): string;
fileExists(path: string): boolean;
@@ -417,12 +417,17 @@ namespace ts {
return this.shimHost.getDefaultLibFileName(JSON.stringify(options));
}
public readDirectory(path: string, extensions?: string[], exclude?: string[], include?: string[]): string[] {
public readDirectory(path: string, extensions?: string[], exclude?: string[], include?: string[], depth?: number): string[] {
const pattern = getFileMatcherPatterns(path, extensions, exclude, include,
this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory());
return JSON.parse(this.shimHost.readDirectory(
path,
extensions ? JSON.stringify(extensions) : undefined,
exclude ? JSON.stringify(exclude) : undefined,
include ? JSON.stringify(include) : undefined
JSON.stringify(extensions),
JSON.stringify(pattern.basePaths),
pattern.excludePattern,
pattern.includeFilePattern,
pattern.includeDirectoryPattern,
depth
));
}