@@ -174,7 +174,7 @@ class Builder {
174174
175175 await this . copyDependencies ( "code-server" , this . rootPath , this . buildPath , {
176176 commit,
177- version : process . env . VERSION ,
177+ version : this . codeServerVersion ,
178178 } )
179179 }
180180
@@ -204,13 +204,17 @@ class Builder {
204204
205205 const vscodeBuildPath = path . join ( this . buildPath , "lib/vscode" )
206206 await this . task ( "copying vs code into build directory" , async ( ) => {
207- await fs . mkdirp ( vscodeBuildPath )
207+ await fs . mkdirp ( path . join ( vscodeBuildPath , "resources/linux" ) )
208208 await Promise . all ( [
209209 fs . move (
210210 path . join ( this . vscodeSourcePath , `out-vscode${ process . env . MINIFY ? "-min" : "" } ` ) ,
211211 path . join ( vscodeBuildPath , "out" ) ,
212212 ) ,
213213 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+ ) ,
214218 ] )
215219 } )
216220
@@ -256,6 +260,38 @@ class Builder {
256260 * Bundles the built code into a binary.
257261 */
258262 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+
259295 const bin = new Binary ( {
260296 mainFile : path . join ( this . buildPath , "out/node/entry.js" ) ,
261297 target : await this . target ( ) ,
0 commit comments