@@ -9,6 +9,8 @@ import { GitpodExtensionContext } from 'gitpod-shared';
9
9
import * as util from 'util' ;
10
10
import * as path from 'path' ;
11
11
12
+ const MAX_EXTENSIONS = 15 ;
13
+
12
14
export interface IExtensionIdentifier {
13
15
id : string ;
14
16
uuid ?: string ;
@@ -41,16 +43,23 @@ export async function initializeRemoteExtensions(extensions: ISyncExtension[], c
41
43
const productJson = await getVSCodeProductJson ( ) ;
42
44
const appName = productJson . applicationName || 'code' ;
43
45
const codeCliPath = path . join ( vscode . env . appRoot , 'bin/remote-cli' , appName ) ;
44
- const args = extensions . map ( e => '--install-extension ' + e . identifier . id ) . join ( ' ' ) ;
45
-
46
46
const execEnv = { ...process . env } ;
47
- delete execEnv [ 'ELECTRON_RUN_AS_NODE' ]
48
- try {
49
- context . logger . info ( 'Trying to initialize remote extensions:' , extensions . map ( e => e . identifier . id ) . join ( '\n' ) ) ;
50
- const { stdout, stderr } = await util . promisify ( cp . exec ) ( `${ codeCliPath } ${ args } ` , { env : execEnv } ) ;
51
- context . logger . info ( `Initialize remote extensions cli commamnd output:\nstdout: ${ stdout } \nstderr: ${ stderr } ` ) ;
52
- } catch ( e ) {
53
- context . logger . error ( 'Error trying to initialize remote extensions:' , e ) ;
47
+ delete execEnv [ 'ELECTRON_RUN_AS_NODE' ] ;
48
+
49
+ context . logger . info ( 'Trying to initialize remote extensions:' , extensions . map ( e => e . identifier . id ) . join ( '\n' ) ) ;
50
+ for ( let i = 0 ; i < extensions . length ; i += MAX_EXTENSIONS ) {
51
+ const extensionsChunk = extensions . slice ( i , i + MAX_EXTENSIONS ) ;
52
+ if ( ! extensionsChunk . length ) {
53
+ break ;
54
+ }
55
+
56
+ try {
57
+ const args = extensionsChunk . map ( e => '--install-extension ' + e . identifier . id ) . join ( ' ' ) ;
58
+ const { stdout, stderr } = await util . promisify ( cp . exec ) ( `${ codeCliPath } ${ args } ` , { env : execEnv } ) ;
59
+ context . logger . info ( `Initialize remote extensions cli commamnd output:\nstdout: ${ stdout } \nstderr: ${ stderr } ` ) ;
60
+ } catch ( e ) {
61
+ context . logger . error ( 'Error trying to initialize remote extensions:' , e ) ;
62
+ }
54
63
}
55
64
56
65
return true ;
@@ -102,15 +111,22 @@ export async function installInitialExtensions(context: GitpodExtensionContext)
102
111
const productJson = await getVSCodeProductJson ( ) ;
103
112
const appName = productJson . applicationName || 'code' ;
104
113
const codeCliPath = path . join ( vscode . env . appRoot , 'bin/remote-cli' , appName ) ;
105
- const args = extensions . map ( e => '--install-extension ' + e . toString ( ) ) . join ( ' ' ) ;
106
-
107
114
const execEnv = { ...process . env } ;
108
- delete execEnv [ 'ELECTRON_RUN_AS_NODE' ]
109
- try {
110
- context . logger . info ( 'Trying to initialize remote extensions from gitpod.yml:' , extensions . map ( e => e . toString ( ) ) . join ( '\n' ) ) ;
111
- const { stdout, stderr } = await util . promisify ( cp . exec ) ( `${ codeCliPath } ${ args } ` , { env : execEnv } ) ;
112
- context . logger . info ( `Initialize remote extensions cli commamnd output:\nstdout: ${ stdout } \nstderr: ${ stderr } ` ) ;
113
- } catch ( e ) {
114
- context . logger . error ( 'Error trying to initialize remote extensions from gitpod.yml:' , e ) ;
115
+ delete execEnv [ 'ELECTRON_RUN_AS_NODE' ] ;
116
+
117
+ context . logger . info ( 'Trying to initialize remote extensions from gitpod.yml:' , extensions . map ( e => e . toString ( ) ) . join ( '\n' ) ) ;
118
+ for ( let i = 0 ; i < extensions . length ; i += MAX_EXTENSIONS ) {
119
+ const extensionsChunk = extensions . slice ( i , i + MAX_EXTENSIONS ) ;
120
+ if ( ! extensionsChunk . length ) {
121
+ break ;
122
+ }
123
+
124
+ try {
125
+ const args = extensionsChunk . map ( e => '--install-extension ' + e . toString ( ) ) . join ( ' ' ) ;
126
+ const { stdout, stderr } = await util . promisify ( cp . exec ) ( `${ codeCliPath } ${ args } ` , { env : execEnv } ) ;
127
+ context . logger . info ( `Initialize remote extensions cli commamnd output:\nstdout: ${ stdout } \nstderr: ${ stderr } ` ) ;
128
+ } catch ( e ) {
129
+ context . logger . error ( 'Error trying to initialize remote extensions from gitpod.yml:' , e ) ;
130
+ }
115
131
}
116
132
}
0 commit comments