Skip to content

Commit 75f35a1

Browse files
grdownsbobbrow
authored andcommitted
Fix CLI mismatch for downgrading (#3065)
1 parent dcc0174 commit 75f35a1

2 files changed

Lines changed: 22 additions & 4 deletions

File tree

Extension/src/LanguageServer/extension.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { Range } from 'vscode-languageclient';
2222
import { ChildProcess, spawn, execSync } from 'child_process';
2323
import * as tmp from 'tmp';
2424
import { getTargetBuildInfo } from '../githubAPI';
25+
import { PackageVersion } from '../packageVersion';
2526

2627
let prevCrashFile: string;
2728
let clients: ClientCollection;
@@ -266,7 +267,25 @@ async function installVsix(vsixLocation: string, updateChannel: string): Promise
266267
return Promise.reject(new Error('Failed to find VS Code script'));
267268
}
268269

269-
// Install the VSIX
270+
// 1.28.0 changes the CLI for making installations
271+
let userVersion: PackageVersion = new PackageVersion(vscode.version);
272+
let breakingVersion: PackageVersion = new PackageVersion('1.28.0');
273+
if (userVersion.isGreaterThan(breakingVersion, 'insider')) {
274+
return new Promise<void>((resolve, reject) => {
275+
let process: ChildProcess;
276+
try {
277+
process = spawn(vsCodeScriptPath, ['--install-extension', vsixLocation, '--force']);
278+
if (process.pid === undefined) {
279+
throw new Error();
280+
}
281+
} catch (error) {
282+
reject(new Error('Failed to launch VS Code script process for installation'));
283+
return;
284+
}
285+
resolve();
286+
});
287+
}
288+
270289
return new Promise<void>((resolve, reject) => {
271290
let process: ChildProcess;
272291
try {

Extension/src/packageVersion.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,8 @@ export class PackageVersion {
4040
}
4141
}
4242

43-
public isGreaterThan(other: PackageVersion): boolean {
44-
// PackageVersions cannot be compared if either have a suffix that is not 'insiders'
45-
if ((this.suffix && !this.suffix.startsWith('insiders')) || (other.suffix && !other.suffix.startsWith('insiders'))) {
43+
public isGreaterThan(other: PackageVersion, suffixStr: string = 'insiders'): boolean {
44+
if ((this.suffix && !this.suffix.startsWith(suffixStr)) || (other.suffix && !other.suffix.startsWith(suffixStr))) {
4645
return false;
4746
}
4847

0 commit comments

Comments
 (0)