Skip to content

Commit 1b9acca

Browse files
authored
use local registry to check if typings package exist (#12014)
use local registry to check if typings package exist
1 parent 4c67000 commit 1b9acca

File tree

4 files changed

+196
-259
lines changed

4 files changed

+196
-259
lines changed

src/harness/unittests/tsserverProjectSystem.ts

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ namespace ts.projectSystem {
1717
};
1818

1919
export interface PostExecAction {
20-
readonly requestKind: TI.RequestKind;
2120
readonly success: boolean;
2221
readonly callback: TI.RequestCompletedAction;
2322
}
@@ -50,9 +49,13 @@ namespace ts.projectSystem {
5049

5150
export class TestTypingsInstaller extends TI.TypingsInstaller implements server.ITypingsInstaller {
5251
protected projectService: server.ProjectService;
53-
constructor(readonly globalTypingsCacheLocation: string, throttleLimit: number, readonly installTypingHost: server.ServerHost, log?: TI.Log) {
54-
super(globalTypingsCacheLocation, safeList.path, throttleLimit, log);
55-
this.init();
52+
constructor(
53+
readonly globalTypingsCacheLocation: string,
54+
throttleLimit: number,
55+
installTypingHost: server.ServerHost,
56+
readonly typesRegistry = createMap<void>(),
57+
log?: TI.Log) {
58+
super(installTypingHost, globalTypingsCacheLocation, safeList.path, throttleLimit, log);
5659
}
5760

5861
safeFileList = safeList.path;
@@ -66,9 +69,8 @@ namespace ts.projectSystem {
6669
}
6770
}
6871

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

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

85-
executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: TI.RequestCompletedAction): void {
86-
switch (requestKind) {
87-
case TI.NpmViewRequest:
88-
case TI.NpmInstallRequest:
89-
break;
90-
default:
91-
assert.isTrue(false, `request ${requestKind} is not supported`);
92-
}
93-
this.addPostExecAction(requestKind, "success", cb);
87+
installWorker(requestId: number, args: string[], cwd: string, cb: TI.RequestCompletedAction): void {
88+
this.addPostExecAction("success", cb);
9489
}
9590

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

105-
addPostExecAction(requestKind: TI.RequestKind, stdout: string | string[], cb: TI.RequestCompletedAction) {
100+
addPostExecAction(stdout: string | string[], cb: TI.RequestCompletedAction) {
106101
const out = typeof stdout === "string" ? stdout : createNpmPackageJsonString(stdout);
107102
const action: PostExecAction = {
108103
success: !!out,
109-
callback: cb,
110-
requestKind
104+
callback: cb
111105
};
112106
this.postExecActions.push(action);
113107
}

0 commit comments

Comments
 (0)