Move createTypesRegistry so more accessible

This commit is contained in:
uniqueiniquity 2018-01-11 13:20:45 -08:00
parent 2a0d5d173d
commit aff02e879c
2 changed files with 28 additions and 22 deletions

View File

@ -126,6 +126,25 @@ namespace ts.projectSystem {
return JSON.stringify({ dependencies });
}
export function createTypesRegistry(...list: string[]): Map<MapLike<string>> {
const versionMap = {
"latest": "1.3.0",
"ts2.0": "1.0.0",
"ts2.1": "1.0.0",
"ts2.2": "1.2.0",
"ts2.3": "1.3.0",
"ts2.4": "1.3.0",
"ts2.5": "1.3.0",
"ts2.6": "1.3.0",
"ts2.7": "1.3.0"
};
const map = createMap<MapLike<string>>();
for (const l of list) {
map.set(l, versionMap);
}
return map;
}
export function toExternalFile(fileName: string): protocol.ExternalFile {
return { fileName };
}
@ -6528,12 +6547,18 @@ namespace ts.projectSystem {
},
})
};
const typingsCachePackageLockJson: FileOrFolder = {
path: `${typingsCache}/package-lock.json`,
content: JSON.stringify({
dependencies: {
},
})
};
const files = [file, packageJsonInCurrentDirectory, packageJsonOfPkgcurrentdirectory, indexOfPkgcurrentdirectory, typingsCachePackageJson];
const files = [file, packageJsonInCurrentDirectory, packageJsonOfPkgcurrentdirectory, indexOfPkgcurrentdirectory, typingsCachePackageJson, typingsCachePackageLockJson];
const host = createServerHost(files, { currentDirectory });
const typesRegistry = createMap<MapLike<string>>();
typesRegistry.set("pkgcurrentdirectory", void 0);
const typesRegistry = createTypesRegistry("pkgcurrentdirectory");
const typingsInstaller = new TestTypingsInstaller(typingsCache, /*throttleLimit*/ 5, host, typesRegistry);
const projectService = createProjectService(host, { typingsInstaller });

View File

@ -14,25 +14,6 @@ namespace ts.projectSystem {
typesRegistry?: Map<MapLike<string>>;
}
function createTypesRegistry(...list: string[]): Map<MapLike<string>> {
const versionMap = {
"latest": "1.3.0",
"ts2.0": "1.0.0",
"ts2.1": "1.0.0",
"ts2.2": "1.2.0",
"ts2.3": "1.3.0",
"ts2.4": "1.3.0",
"ts2.5": "1.3.0",
"ts2.6": "1.3.0",
"ts2.7": "1.3.0"
};
const map = createMap<MapLike<string>>();
for (const l of list) {
map.set(l, versionMap);
}
return map;
}
class Installer extends TestTypingsInstaller {
constructor(host: server.ServerHost, p?: InstallerParams, log?: TI.Log) {
super(