Skip to content

Commit 536685c

Browse files
authored
Grdowns/update channel fix (#2637)
* Use shell optional arg * Add try/catch around spawn to override any possible exceptions * Default vsixname to cpptools-linux32.vsix * Move logFailure inline * Remove potential PII from error message to be on the safe side * Fix linter errors * Remove spawn optional arg; instead remove quotes surrounding command * Remove rethrowing of error at the top level checkAndApplyUpdate * Commenting * Remove default case in switch statement for vsixName; Add x86, i383, i686 cases
1 parent b6f1847 commit 536685c

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

Extension/src/LanguageServer/extension.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,10 @@ async function installVsix(vsixLocation: string, updateChannel: string): Promise
242242
cmdFile = 'code.cmd';
243243
}
244244
const vsCodeExeDir: string = path.dirname(process.execPath);
245-
return '"' + path.join(vsCodeExeDir, 'bin', cmdFile) + '"';
245+
return path.join(vsCodeExeDir, 'bin', cmdFile);
246246
} else if (platformInfo.platform === 'darwin') {
247-
return '"' + path.join(process.execPath, '..', '..', '..', '..', '..',
248-
'Resources', 'app', 'bin', 'code') + '"';
247+
return path.join(process.execPath, '..', '..', '..', '..', '..',
248+
'Resources', 'app', 'bin', 'code');
249249
} else {
250250
const vsCodeBinName: string = path.basename(process.execPath);
251251
try {
@@ -262,8 +262,13 @@ async function installVsix(vsixLocation: string, updateChannel: string): Promise
262262

263263
// Install the VSIX
264264
return new Promise<void>((resolve, reject) => {
265-
let process: ChildProcess = spawn(vsCodeScriptPath, ['--install-extension', vsixLocation]);
266-
if (process.pid === undefined) {
265+
let process: ChildProcess;
266+
try {
267+
process = spawn(vsCodeScriptPath, ['--install-extension', vsixLocation]);
268+
if (process.pid === undefined) {
269+
throw new Error();
270+
}
271+
} catch (error) {
267272
reject(new Error('Failed to launch VS Code script process for installation'));
268273
return;
269274
}
@@ -296,10 +301,6 @@ async function installVsix(vsixLocation: string, updateChannel: string): Promise
296301
* @param updateChannel The user's updateChannel setting.
297302
*/
298303
async function checkAndApplyUpdate(updateChannel: string): Promise<void> {
299-
// Helper fn to avoid code duplication
300-
let logFailure: (error: Error) => void = (error: Error) => {
301-
telemetry.logLanguageServerEvent('installVsix', { 'error': error.message, 'success': 'false' });
302-
};
303304
// Wrap in new Promise to allow tmp.file callback to successfully resolve/reject
304305
// as tmp.file does not do anything with the callback functions return value
305306
const p: Promise<void> = new Promise<void>((resolve, reject) => {
@@ -344,8 +345,10 @@ async function checkAndApplyUpdate(updateChannel: string): Promise<void> {
344345
});
345346
await p.catch((error: Error) => {
346347
// Handle .then following getTargetBuildInfo rejection
347-
logFailure(error);
348-
throw error;
348+
if (error.message.indexOf('/') !== -1 || error.message.indexOf('\\') !== -1) {
349+
error.message = "Potential PII hidden";
350+
}
351+
telemetry.logLanguageServerEvent('installVsix', { 'error': error.message, 'success': 'false' });
349352
});
350353
}
351354

Extension/src/githubAPI.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,10 @@ function vsixNameForPlatform(info: PlatformInformation): string {
100100
case 'darwin': return 'cpptools-osx.vsix';
101101
default: {
102102
switch (platformInfo.architecture) {
103-
case 'x86': return 'cpptools-linux32.vsix';
104103
case 'x86_64': return 'cpptools-linux.vsix';
104+
case 'x86':
105+
case 'i386':
106+
case 'i686': return 'cpptools-linux32.vsix';
105107
}
106108
}
107109
}

0 commit comments

Comments
 (0)