@@ -158,21 +158,28 @@ class Builder {
158
158
} ) ;
159
159
160
160
// Download and prepare VS Code if necessary (should be cached by CI).
161
- const exists = fs . existsSync ( vscodeSourcePath ) ;
162
- if ( exists ) {
163
- this . log ( "Using existing VS Code directory" ) ;
161
+ if ( fs . existsSync ( vscodeSourcePath ) ) {
162
+ this . log ( "Using existing VS Code clone" ) ;
164
163
} else {
165
164
await this . task ( "Cloning VS Code" , ( ) => {
166
165
return util . promisify ( cp . exec ) (
167
166
"git clone https://github.com/microsoft/vscode"
168
167
+ ` --quiet --branch "${ vscodeVersion } "`
169
168
+ ` --single-branch --depth=1 "${ vscodeSourcePath } "` ) ;
170
169
} ) ;
170
+ }
171
171
172
+ if ( fs . existsSync ( path . join ( vscodeSourcePath , "node_modules" ) ) ) {
173
+ this . log ( "Using existing VS Code node_modules" ) ;
174
+ } else {
172
175
await this . task ( "Installing VS Code dependencies" , ( ) => {
173
176
return util . promisify ( cp . exec ) ( "yarn" , { cwd : vscodeSourcePath } ) ;
174
177
} ) ;
178
+ }
175
179
180
+ if ( fs . existsSync ( path . join ( vscodeSourcePath , ".build/extensions" ) ) ) {
181
+ this . log ( "Using existing built-in-extensions" ) ;
182
+ } else {
176
183
await this . task ( "Building default extensions" , ( ) => {
177
184
return util . promisify ( cp . exec ) (
178
185
"yarn gulp compile-extensions-build --max-old-space-size=32384" ,
@@ -296,8 +303,16 @@ class Builder {
296
303
] ) ;
297
304
} ) ;
298
305
299
- // This is so it doesn't get cached along with VS Code (no point).
300
- await this . task ( "Removing copied server" , ( ) => fs . remove ( serverPath ) ) ;
306
+ // This is so it doesn't get cached along with VS Code. There's no point
307
+ // since there isn't anything like an incremental build.
308
+ await this . task ( "Removing build files for smaller cache" , ( ) => {
309
+ return Promise . all ( [
310
+ fs . remove ( serverPath ) ,
311
+ fs . remove ( path . join ( vscodeSourcePath , "out-vscode" ) ) ,
312
+ fs . remove ( path . join ( vscodeSourcePath , "out-vscode-min" ) ) ,
313
+ fs . remove ( path . join ( vscodeSourcePath , "out-build" ) ) ,
314
+ ] ) ;
315
+ } ) ;
301
316
302
317
// Prepend code to the target which enables finding files within the binary.
303
318
const prependLoader = async ( relativeFilePath : string ) : Promise < void > => {
@@ -326,19 +341,25 @@ class Builder {
326
341
] ) ;
327
342
} ) ;
328
343
329
- // TODO: fix onigasm dep
330
- // # onigasm 2.2.2 has a bug that makes it broken for PHP files so use 2.2.1.
331
- // # https://github.com/NeekSandhu/onigasm/issues/17
332
- // function fix-onigasm() {
333
- // local onigasmPath="${buildPath}/node_modules/onigasm-umd"
334
- // rm -rf "${onigasmPath}"
335
- // git clone "https://github.com/alexandrudima/onigasm-umd" "${onigasmPath}"
336
- // cd "${onigasmPath}" && yarn && yarn add --dev [email protected] && yarn package
337
- // mkdir "${onigasmPath}-temp"
338
- // mv "${onigasmPath}/"{release,LICENSE} "${onigasmPath}-temp"
339
- // rm -rf "${onigasmPath}"
340
- // mv "${onigasmPath}-temp" "${onigasmPath}"
341
- // }
344
+ // onigasm 2.2.2 has a bug that makes it broken for PHP files so use 2.2.1.
345
+ // https://github.com/NeekSandhu/onigasm/issues/17
346
+ await this . task ( "Applying onigasm PHP fix" , async ( ) => {
347
+ const onigasmPath = path . join ( finalBuildPath , "node_modules/onigasm-umd" ) ;
348
+ const onigasmTmpPath = `${ onigasmPath } -temp` ;
349
+ await Promise . all ( [
350
+ fs . remove ( onigasmPath ) ,
351
+ fs . mkdir ( onigasmTmpPath ) ,
352
+ ] ) ;
353
+ await util . promisify ( cp . exec ) ( `git clone "https://github.com/alexandrudima/onigasm-umd" "${ onigasmPath } "` ) ;
354
+ await util . promisify ( cp . exec ) ( "yarn" , { cwd : onigasmPath } ) ;
355
+ await util . promisify ( cp . exec ) ( "yarn add --dev [email protected] " , { cwd :
onigasmPath } ) ;
356
+ await util . promisify ( cp . exec ) ( "yarn package" , { cwd : onigasmPath } ) ;
357
+ await Promise . all ( [ "release" , "LICENSE" , "package.json" ] . map ( ( fileName ) => {
358
+ return fs . copy ( path . join ( onigasmPath , fileName ) , path . join ( onigasmTmpPath , fileName ) ) ;
359
+ } ) ) ;
360
+ await fs . remove ( onigasmPath ) ;
361
+ await fs . move ( onigasmTmpPath , onigasmPath ) ;
362
+ } ) ;
342
363
343
364
this . log ( `Final build: ${ finalBuildPath } ` ) ;
344
365
}
0 commit comments