@@ -172,22 +172,7 @@ 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
- )
190
- } )
175
+ await this . copyDependencies ( "code-server" , this . rootPath , this . buildPath , commit )
191
176
}
192
177
193
178
private async buildVscode ( commit : string ) : Promise < void > {
@@ -214,34 +199,6 @@ class Builder {
214
199
} )
215
200
}
216
201
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
202
const vscodeBuildPath = path . join ( this . buildPath , "lib/vscode" )
246
203
await this . task ( "copying vs code into build directory" , async ( ) => {
247
204
await fs . mkdirp ( vscodeBuildPath )
@@ -254,14 +211,10 @@ class Builder {
254
211
] )
255
212
} )
256
213
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 ) )
261
- } )
214
+ await this . copyDependencies ( "vs code" , this . vscodeSourcePath , vscodeBuildPath , commit )
262
215
}
263
216
264
- private async copyDependencies ( name : string , sourcePath : string , buildPath : string ) : Promise < void > {
217
+ private async copyDependencies ( name : string , sourcePath : string , buildPath : string , commit : string ) : Promise < void > {
265
218
await this . task ( `copying ${ name } dependencies` , async ( ) => {
266
219
return Promise . all (
267
220
[ "node_modules" , "package.json" , "yarn.lock" ] . map ( ( fileName ) => {
@@ -270,6 +223,23 @@ class Builder {
270
223
)
271
224
} )
272
225
226
+ const fileName = name === "code-server" ? "package" : "product"
227
+ await this . task ( "writing final ${name} ${fileName}.json" , async ( ) => {
228
+ const json = JSON . parse ( await fs . readFile ( path . join ( sourcePath , `${ fileName } .json` ) , "utf8" ) )
229
+ return fs . writeFile (
230
+ path . join ( buildPath , `${ fileName } .json` ) ,
231
+ JSON . stringify (
232
+ {
233
+ ...json ,
234
+ commit,
235
+ date : new Date ( ) . toISOString ( ) ,
236
+ } ,
237
+ null ,
238
+ 2
239
+ )
240
+ )
241
+ } )
242
+
273
243
if ( process . env . MINIFY ) {
274
244
await this . task ( `restricting ${ name } to production dependencies` , async ( ) => {
275
245
return util . promisify ( cp . exec ) ( "yarn --production --ignore-scripts" , { cwd : buildPath } )
0 commit comments