Skip to content

Commit

Permalink
use local registry to check if typings package exist (#12014)
Browse files Browse the repository at this point in the history
use local registry to check if typings package exist
  • Loading branch information
vladima authored Nov 3, 2016
1 parent 4c67000 commit 1b9acca
Show file tree
Hide file tree
Showing 4 changed files with 196 additions and 259 deletions.
32 changes: 13 additions & 19 deletions src/harness/unittests/tsserverProjectSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ namespace ts.projectSystem {
};

export interface PostExecAction {
readonly requestKind: TI.RequestKind;
readonly success: boolean;
readonly callback: TI.RequestCompletedAction;
}
Expand Down Expand Up @@ -50,9 +49,13 @@ namespace ts.projectSystem {

export class TestTypingsInstaller extends TI.TypingsInstaller implements server.ITypingsInstaller {
protected projectService: server.ProjectService;
constructor(readonly globalTypingsCacheLocation: string, throttleLimit: number, readonly installTypingHost: server.ServerHost, log?: TI.Log) {
super(globalTypingsCacheLocation, safeList.path, throttleLimit, log);
this.init();
constructor(
readonly globalTypingsCacheLocation: string,
throttleLimit: number,
installTypingHost: server.ServerHost,
readonly typesRegistry = createMap<void>(),
log?: TI.Log) {
super(installTypingHost, globalTypingsCacheLocation, safeList.path, throttleLimit, log);
}

safeFileList = safeList.path;
Expand All @@ -66,9 +69,8 @@ namespace ts.projectSystem {
}
}

checkPendingCommands(expected: TI.RequestKind[]) {
assert.equal(this.postExecActions.length, expected.length, `Expected ${expected.length} post install actions`);
this.postExecActions.forEach((act, i) => assert.equal(act.requestKind, expected[i], "Unexpected post install action"));
checkPendingCommands(expectedCount: number) {
assert.equal(this.postExecActions.length, expectedCount, `Expected ${expectedCount} post install actions`);
}

onProjectClosed(p: server.Project) {
Expand All @@ -82,15 +84,8 @@ namespace ts.projectSystem {
return this.installTypingHost;
}

executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: TI.RequestCompletedAction): void {
switch (requestKind) {
case TI.NpmViewRequest:
case TI.NpmInstallRequest:
break;
default:
assert.isTrue(false, `request ${requestKind} is not supported`);
}
this.addPostExecAction(requestKind, "success", cb);
installWorker(requestId: number, args: string[], cwd: string, cb: TI.RequestCompletedAction): void {
this.addPostExecAction("success", cb);
}

sendResponse(response: server.SetTypings | server.InvalidateCachedTypings) {
Expand All @@ -102,12 +97,11 @@ namespace ts.projectSystem {
this.install(request);
}

addPostExecAction(requestKind: TI.RequestKind, stdout: string | string[], cb: TI.RequestCompletedAction) {
addPostExecAction(stdout: string | string[], cb: TI.RequestCompletedAction) {
const out = typeof stdout === "string" ? stdout : createNpmPackageJsonString(stdout);
const action: PostExecAction = {
success: !!out,
callback: cb,
requestKind
callback: cb
};
this.postExecActions.push(action);
}
Expand Down
Loading

0 comments on commit 1b9acca

Please sign in to comment.