@@ -69,30 +69,38 @@ export async function prepareVSCodeAndExecuteTests(
6969
7070async function installExtensions ( extensionIds : string [ ] , vscodeCli : string , vscodeArgs : string [ ] ) : Promise < void > {
7171 for ( const extensionId of extensionIds ) {
72- const argsWithExtension = [ ...vscodeArgs , '--install-extension' , extensionId ] ;
73-
74- // Since we're using shell execute, spaces in the CLI path will get interpeted as args
75- // Therefore we wrap the CLI path in quotes as on MacOS the path can contain spaces.
76- const cliWrapped = `"${ vscodeCli } "` ;
77- console . log ( `${ cliWrapped } ${ argsWithExtension } ` ) ;
78-
79- const result = cp . spawnSync ( cliWrapped , argsWithExtension , {
80- encoding : 'utf-8' ,
81- stdio : 'inherit' ,
82- // Workaround as described in https://github.com/nodejs/node/issues/52554
83- shell : true ,
84- } ) ;
85- if ( result . error || result . status !== 0 ) {
86- throw new Error ( `Failed to install extensions: ${ JSON . stringify ( result ) } ` ) ;
72+ try {
73+ await installExtension ( extensionId , vscodeCli , vscodeArgs ) ;
74+ } catch ( error ) {
75+ console . warn ( `Failed to install extension; retrying ${ extensionId } : ${ error } ` ) ;
76+ // Workaround for https://github.com/microsoft/vscode/issues/256031 to install extensions one at a time with a delay.
77+ await new Promise ( ( resolve ) => setTimeout ( resolve , 2000 ) ) ;
78+ await installExtension ( extensionId , vscodeCli , vscodeArgs ) ;
8779 }
88-
89- // Workaround for https://github.com/microsoft/vscode/issues/256031 to install extensions one at a time with a delay.
90- await new Promise ( ( resolve ) => setTimeout ( resolve , 2000 ) ) ;
9180 }
9281
9382 console . log ( ) ;
9483}
9584
85+ async function installExtension ( extensionId : string , vscodeCli : string , vscodeArgs : string [ ] ) : Promise < void > {
86+ const argsWithExtension = [ ...vscodeArgs , '--install-extension' , extensionId ] ;
87+
88+ // Since we're using shell execute, spaces in the CLI path will get interpeted as args
89+ // Therefore we wrap the CLI path in quotes as on MacOS the path can contain spaces.
90+ const cliWrapped = `"${ vscodeCli } "` ;
91+ console . log ( `${ cliWrapped } ${ argsWithExtension } ` ) ;
92+
93+ const result = cp . spawnSync ( cliWrapped , argsWithExtension , {
94+ encoding : 'utf-8' ,
95+ stdio : 'inherit' ,
96+ // Workaround as described in https://github.com/nodejs/node/issues/52554
97+ shell : true ,
98+ } ) ;
99+ if ( result . error || result . status !== 0 ) {
100+ throw new Error ( `Failed to install extensions: ${ JSON . stringify ( result ) } ` ) ;
101+ }
102+ }
103+
96104function getSln ( workspacePath : string ) : string | undefined {
97105 if ( workspacePath . endsWith ( 'slnWithGenerator' ) ) {
98106 return 'slnWithGenerator.sln' ;
0 commit comments