@@ -172,21 +172,9 @@ class Builder {
172
172
] )
173
173
} )
174
174
175
- await this . copyDependencies ( "code-server" , this . rootPath , this . buildPath )
176
-
177
- await this . task ( "writing final code-server package.json" , async ( ) => {
178
- const json = JSON . parse ( await fs . readFile ( path . join ( this . buildPath , "package.json" ) , "utf8" ) )
179
- return fs . writeFile (
180
- path . join ( this . buildPath , "package.json" ) ,
181
- JSON . stringify (
182
- {
183
- ...json ,
184
- commit,
185
- } ,
186
- null ,
187
- 2
188
- )
189
- )
175
+ await this . copyDependencies ( "code-server" , this . rootPath , this . buildPath , {
176
+ commit,
177
+ version : process . env . VERSION ,
190
178
} )
191
179
}
192
180
@@ -214,34 +202,6 @@ class Builder {
214
202
} )
215
203
}
216
204
217
- const { productJson, packageJson } = await this . task ( "generating vs code product configuration" , async ( ) => {
218
- const merge = async ( name : string , json : { [ key : string ] : string } = { } ) : Promise < { [ key : string ] : string } > => {
219
- return {
220
- ...JSON . parse ( await fs . readFile ( path . join ( this . vscodeSourcePath , `${ name } .json` ) , "utf8" ) ) ,
221
- ...json ,
222
- }
223
- }
224
-
225
- const date = new Date ( ) . toISOString ( )
226
- const [ packageJson , productJson ] = await Promise . all ( [ merge ( "package" , { } ) , merge ( "product" , { commit, date } ) ] )
227
-
228
- return { productJson, packageJson }
229
- } )
230
-
231
- await this . task ( "inserting vs code product configuration" , async ( ) => {
232
- const filePath = path . join ( this . vscodeSourcePath , "out-build/vs/platform/product/common/product.js" )
233
- return fs . writeFile (
234
- filePath ,
235
- ( await fs . readFile ( filePath , "utf8" ) ) . replace (
236
- "{ /*BUILD->INSERT_PRODUCT_CONFIGURATION*/}" ,
237
- JSON . stringify ( {
238
- version : packageJson . version ,
239
- ...productJson ,
240
- } )
241
- )
242
- )
243
- } )
244
-
245
205
const vscodeBuildPath = path . join ( this . buildPath , "lib/vscode" )
246
206
await this . task ( "copying vs code into build directory" , async ( ) => {
247
207
await fs . mkdirp ( vscodeBuildPath )
@@ -254,14 +214,13 @@ class Builder {
254
214
] )
255
215
} )
256
216
257
- await this . copyDependencies ( "vs code" , this . vscodeSourcePath , vscodeBuildPath )
258
-
259
- await this . task ( "writing final vs code product.json" , ( ) => {
260
- return fs . writeFile ( path . join ( vscodeBuildPath , "product.json" ) , JSON . stringify ( productJson , null , 2 ) )
217
+ await this . copyDependencies ( "vs code" , this . vscodeSourcePath , vscodeBuildPath , {
218
+ commit,
219
+ date : new Date ( ) . toISOString ( ) ,
261
220
} )
262
221
}
263
222
264
- private async copyDependencies ( name : string , sourcePath : string , buildPath : string ) : Promise < void > {
223
+ private async copyDependencies ( name : string , sourcePath : string , buildPath : string , merge : object ) : Promise < void > {
265
224
await this . task ( `copying ${ name } dependencies` , async ( ) => {
266
225
return Promise . all (
267
226
[ "node_modules" , "package.json" , "yarn.lock" ] . map ( ( fileName ) => {
@@ -270,6 +229,22 @@ class Builder {
270
229
)
271
230
} )
272
231
232
+ const fileName = name === "code-server" ? "package" : "product"
233
+ await this . task ( `writing final ${ name } ${ fileName } .json` , async ( ) => {
234
+ const json = JSON . parse ( await fs . readFile ( path . join ( sourcePath , `${ fileName } .json` ) , "utf8" ) )
235
+ return fs . writeFile (
236
+ path . join ( buildPath , `${ fileName } .json` ) ,
237
+ JSON . stringify (
238
+ {
239
+ ...json ,
240
+ ...merge ,
241
+ } ,
242
+ null ,
243
+ 2
244
+ )
245
+ )
246
+ } )
247
+
273
248
if ( process . env . MINIFY ) {
274
249
await this . task ( `restricting ${ name } to production dependencies` , async ( ) => {
275
250
return util . promisify ( cp . exec ) ( "yarn --production --ignore-scripts" , { cwd : buildPath } )
0 commit comments