Archived
1
0
This repository has been archived on 2024-09-09. You can view files and clone it, but cannot push or open issues or pull requests.
code-server/packages/server/scripts/nexe.js
Kyle Carberry 676b30934f
Add ripgrep, fill native fs functions, add ping endpoint (#39)
* Add ripgrep, fill native fs functions, add ping endpoint

* Make show in folder redirect to the workspace
2019-02-27 15:12:26 -06:00

31 lines
1.3 KiB
JavaScript

const fs = require("fs");
const fse = require("fs-extra");
const os = require("os");
const path = require("path");
const nexePath = require.resolve("nexe");
const shimPath = path.join(path.dirname(nexePath), "lib/steps/shim.js");
let shimContent = fs.readFileSync(shimPath).toString();
const replaceString = `global.nativeFs = { existsSync: originalExistsSync, readFile: originalReadFile, readFileSync: originalReadFileSync, createReadStream: originalCreateReadStream, readdir: originalReaddir, readdirSync: originalReaddirSync, statSync: originalStatSync, stat: originalStat, realpath: originalRealpath, realpathSync: originalRealpathSync };`;
shimContent = shimContent.replace(/compiler\.options\.resources\.length[\s\S]*wrap\("(.*\\n)"/g, (om, a) => {
return om.replace(a, `${a}${replaceString}`);
});
fs.writeFileSync(shimPath, shimContent);
const nexe = require("nexe");
nexe.compile({
debugBundle: true,
input: path.join(__dirname, "../out/cli.js"),
output: `cli-${process.env.TRAVIS_OS_NAME || os.platform()}`,
targets: [os.platform()],
/**
* To include native extensions, do NOT install node_modules for each one. They
* are not required as each extension is built using webpack.
*/
resources: [
path.join(__dirname, "../package.json"),
path.join(__dirname, "../build/**/*"),
],
});