Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit63e18af

Browse files
grdownsbobbrow
authored andcommitted
Update Channel pt 3 (microsoft#2543)
* Instead of uninstalling then installing, install and override when prompted
1 parentfcdcd80 commit63e18af

File tree

1 file changed

+36
-18
lines changed

1 file changed

+36
-18
lines changed

‎Extension/src/LanguageServer/extension.ts‎

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { getLanguageConfig } from './languageConfig';
1919
import{getCustomConfigProviders}from'./customProviders';
2020
import{PlatformInformation}from'../platform';
2121
import{Range}from'vscode-languageclient';
22-
import{execSync}from'child_process';
22+
import{ChildProcess,spawn,execSync}from'child_process';
2323
import*astmpfrom'tmp';
2424
import{getTargetBuildInfo}from'../githubAPI';
2525

@@ -235,8 +235,7 @@ async function installVsix(vsixLocation: string, updateChannel: string): Promise
235235
constvsCodeScriptPath:string=function(platformInfo):string{
236236
if(platformInfo.platform==='win32'){
237237
constvsCodeBinName:string=path.basename(process.execPath);
238-
// Windows VS Code Insiders breaks VS Code naming conventions
239-
letcmdFile:string;
238+
letcmdFile:string;// Windows VS Code Insiders breaks VS Code naming conventions
240239
if(vsCodeBinName==='Code - Insiders.exe'){
241240
cmdFile='code-insiders.cmd';
242241
}else{
@@ -249,27 +248,45 @@ async function installVsix(vsixLocation: string, updateChannel: string): Promise
249248
'Resources','app','bin','code')+'"';
250249
}else{
251250
constvsCodeBinName:string=path.basename(process.execPath);
252-
conststdout:Buffer=execSync('which '+vsCodeBinName);
253-
returnstdout.toString().trim();
251+
try{
252+
conststdout:Buffer=execSync('which '+vsCodeBinName);
253+
returnstdout.toString().trim();
254+
}catch(error){
255+
returnundefined;
256+
}
254257
}
255258
}(platformInfo);
256259
if(!vsCodeScriptPath){
257260
returnPromise.reject(newError('Failed to find VS Code script'));
258261
}
259262

260263
// Install the VSIX
261-
constinstallCommand:string=vsCodeScriptPath+' --install-extension '+vsixLocation;
262-
try{
263-
if(updateChannel==='Default'){
264-
// Uninstall the current version, as the version to install is a previous version
265-
constuninstallCommand:string=vsCodeScriptPath+' --uninstall-extension ms-vscode.cpptools';
266-
execSync(uninstallCommand);
264+
returnnewPromise<void>((resolve,reject)=>{
265+
letprocess:ChildProcess=spawn(vsCodeScriptPath,['--install-extension',vsixLocation]);
266+
if(process.pid===undefined){
267+
reject(newError('Failed to launch VS Code script process for installation'));
268+
return;
267269
}
268-
execSync(installCommand);
269-
returnPromise.resolve();
270-
}catch(error){
271-
returnPromise.reject(newError('Failed to install VSIX'));
272-
}
270+
271+
// Timeout the process if no response is sent back. Ensures this Promise resolves/rejects
272+
consttimer:NodeJS.Timer=setTimeout(()=>{
273+
process.kill();
274+
reject(newError('Failed to receive response from VS Code script process for installation within 10s.'));
275+
},10000);
276+
277+
// If downgrading, the VS Code CLI will prompt whether the user is sure they would like to downgrade.
278+
// Respond to this by writing 0 to stdin (the option to override and install the VSIX package)
279+
letsentOverride:boolean=false;
280+
process.stdout.on('data',()=>{
281+
if(sentOverride){
282+
return;
283+
}
284+
process.stdin.write('0\n');
285+
sentOverride=true;
286+
clearInterval(timer);
287+
resolve();
288+
});
289+
});
273290
});
274291
}
275292

@@ -313,8 +330,9 @@ async function checkAndApplyUpdate(updateChannel: string): Promise<void> {
313330
return;
314331
}
315332
clearInterval(insiderUpdateTimer);
316-
util.promptReloadWindow(`The C/C++ Extension has been updated to version${buildInfo.name}. \
317-
Please reload the window for the changes to take effect.`);
333+
constmessage:string=
334+
`The C/C++ Extension has been updated to version${buildInfo.name}. Please reload the window for the changes to take effect.`;
335+
util.promptReloadWindow(message);
318336
telemetry.logLanguageServerEvent('installVsix',{'success':'true'});
319337

320338
resolve();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp