Skip to content

Commit 3ca90a5

Browse files
committed
Use nbin in forked processes
1 parent 6156eb9 commit 3ca90a5

3 files changed

Lines changed: 24 additions & 10 deletions

File tree

main.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1 @@
1-
try {
2-
const nbin = require("nbin");
3-
const path = require("path");
4-
const rootPath = path.resolve(__dirname, "../../..");
5-
console.log("Shimming", rootPath);
6-
nbin.shimNativeFs(rootPath);
7-
} catch (error) {
8-
console.log("Not in the binary");
9-
}
10-
111
require("../../bootstrap-amd").load("vs/server/cli");

scripts/nbin-loader.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
if (!global.NBIN_LOADED) {
2+
try {
3+
const nbin = require("nbin");
4+
nbin.shimNativeFs("{{ROOT_PATH}}");
5+
global.NBIN_LOADED = true;
6+
} catch (error) {
7+
console.log("Not in the binary");
8+
}
9+
}

scripts/tasks.bash

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ function copy-server() {
4141
fi
4242
}
4343

44+
# Prepend the nbin loading code which allows the code to find files within
45+
# the binary.
46+
function prepend-loader() {
47+
local filePath="${codeServerBuildPath}/${1}" ; shift
48+
cat "${rootPath}/scripts/nbin-loader.js" "${filePath}" > "${filePath}.temp"
49+
mv "${filePath}.temp" "${filePath}"
50+
# Using : as the delimiter so the escaping here is easier to read.
51+
# ${parameter/pattern/string}, so the pattern is /: (if the pattern starts
52+
# with / it matches all instances) and the string is \\: (results in \:).
53+
sed -i "s:{{ROOT_PATH}}:${codeServerBuildPath//:/\\:}:g" "${filePath}"
54+
}
55+
4456
# Copy code-server into VS Code then build it.
4557
function build-code-server() {
4658
copy-server
@@ -62,6 +74,9 @@ function build-code-server() {
6274
rm -rf "${codeServerBuildPath}/out/vs/server/node_modules"
6375
cp -r "${vscodeSourcePath}/remote/node_modules" "${codeServerBuildPath}"
6476

77+
prepend-loader "out/vs/server/main.js"
78+
prepend-loader "out/bootstrap-fork.js"
79+
6580
log "Final build: ${codeServerBuildPath}"
6681
}
6782

0 commit comments

Comments
 (0)