Use nbin in forked processes

This commit is contained in:
Asher 2019-07-05 11:54:04 -05:00
parent 6156eb9ff4
commit 3ca90a5f89
No known key found for this signature in database
GPG Key ID: D63C1EF81242354A
3 changed files with 24 additions and 10 deletions

10
main.js
View File

@ -1,11 +1 @@
try {
const nbin = require("nbin");
const path = require("path");
const rootPath = path.resolve(__dirname, "../../..");
console.log("Shimming", rootPath);
nbin.shimNativeFs(rootPath);
} catch (error) {
console.log("Not in the binary");
}
require("../../bootstrap-amd").load("vs/server/cli");

9
scripts/nbin-loader.js Normal file
View File

@ -0,0 +1,9 @@
if (!global.NBIN_LOADED) {
try {
const nbin = require("nbin");
nbin.shimNativeFs("{{ROOT_PATH}}");
global.NBIN_LOADED = true;
} catch (error) {
console.log("Not in the binary");
}
}

View File

@ -41,6 +41,18 @@ function copy-server() {
fi
}
# Prepend the nbin loading code which allows the code to find files within
# the binary.
function prepend-loader() {
local filePath="${codeServerBuildPath}/${1}" ; shift
cat "${rootPath}/scripts/nbin-loader.js" "${filePath}" > "${filePath}.temp"
mv "${filePath}.temp" "${filePath}"
# Using : as the delimiter so the escaping here is easier to read.
# ${parameter/pattern/string}, so the pattern is /: (if the pattern starts
# with / it matches all instances) and the string is \\: (results in \:).
sed -i "s:{{ROOT_PATH}}:${codeServerBuildPath//:/\\:}:g" "${filePath}"
}
# Copy code-server into VS Code then build it.
function build-code-server() {
copy-server
@ -62,6 +74,9 @@ function build-code-server() {
rm -rf "${codeServerBuildPath}/out/vs/server/node_modules"
cp -r "${vscodeSourcePath}/remote/node_modules" "${codeServerBuildPath}"
prepend-loader "out/vs/server/main.js"
prepend-loader "out/bootstrap-fork.js"
log "Final build: ${codeServerBuildPath}"
}