@@ -174,7 +174,7 @@ class Builder {
174
174
175
175
await this . copyDependencies ( "code-server" , this . rootPath , this . buildPath , {
176
176
commit,
177
- version : process . env . VERSION ,
177
+ version : this . codeServerVersion ,
178
178
} )
179
179
}
180
180
@@ -204,13 +204,17 @@ class Builder {
204
204
205
205
const vscodeBuildPath = path . join ( this . buildPath , "lib/vscode" )
206
206
await this . task ( "copying vs code into build directory" , async ( ) => {
207
- await fs . mkdirp ( vscodeBuildPath )
207
+ await fs . mkdirp ( path . join ( vscodeBuildPath , "resources/linux" ) )
208
208
await Promise . all ( [
209
209
fs . move (
210
210
path . join ( this . vscodeSourcePath , `out-vscode${ process . env . MINIFY ? "-min" : "" } ` ) ,
211
211
path . join ( vscodeBuildPath , "out" ) ,
212
212
) ,
213
213
fs . copy ( path . join ( this . vscodeSourcePath , ".build/extensions" ) , path . join ( vscodeBuildPath , "extensions" ) ) ,
214
+ fs . copy (
215
+ path . join ( this . vscodeSourcePath , "resources/linux/code.png" ) ,
216
+ path . join ( vscodeBuildPath , "resources/linux/code.png" ) ,
217
+ ) ,
214
218
] )
215
219
} )
216
220
@@ -256,6 +260,38 @@ class Builder {
256
260
* Bundles the built code into a binary.
257
261
*/
258
262
private async binary ( binaryName : string ) : Promise < void > {
263
+ // Prepend code to the target which enables finding files within the binary.
264
+ const prependLoader = async ( relativeFilePath : string ) : Promise < void > => {
265
+ const filePath = path . join ( this . buildPath , relativeFilePath )
266
+ const shim = `
267
+ if (!global.NBIN_LOADED) {
268
+ try {
269
+ const nbin = require("nbin");
270
+ nbin.shimNativeFs("${ this . buildPath } ");
271
+ global.NBIN_LOADED = true;
272
+ const path = require("path");
273
+ const rg = require("vscode-ripgrep");
274
+ rg.binaryRgPath = rg.rgPath;
275
+ rg.rgPath = path.join(require("os").tmpdir(), "code-server", path.basename(rg.binaryRgPath));
276
+ } catch (error) { /* Not in the binary. */ }
277
+ }
278
+ `
279
+ const content = await fs . readFile ( filePath , "utf8" )
280
+ if ( ! content . startsWith ( shim ) ) {
281
+ await fs . writeFile ( filePath , shim + content )
282
+ }
283
+ }
284
+
285
+ await this . task ( "Prepending nbin loader" , ( ) => {
286
+ return Promise . all ( [
287
+ prependLoader ( "out/node/entry.js" ) ,
288
+ prependLoader ( "lib/vscode/out/vs/server/entry.js" ) ,
289
+ prependLoader ( "lib/vscode/out/vs/server/fork.js" ) ,
290
+ prependLoader ( "lib/vscode/out/bootstrap-fork.js" ) ,
291
+ prependLoader ( "lib/vscode/extensions/node_modules/typescript/lib/tsserver.js" ) ,
292
+ ] )
293
+ } )
294
+
259
295
const bin = new Binary ( {
260
296
mainFile : path . join ( this . buildPath , "out/node/entry.js" ) ,
261
297
target : await this . target ( ) ,
0 commit comments