mirror of
https://github.com/coder/code-server.git
synced 2024-12-19 15:52:01 +03:00
994531d8bb
* Add task for packaging release * Modify package task to package a single binary This is so it can be used as part of the build/release script. * Package release as part of Travis deploy * Set platform env var * Add arch env var * Make version available to the code * Use tar for Linux and zip for Mac & Windows
32 lines
1.3 KiB
JavaScript
32 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");
|
|
|
|
const target = `${os.platform()}-${os.arch()}`;
|
|
nexe.compile({
|
|
debugBundle: true,
|
|
input: path.join(__dirname, "../out/cli.js"),
|
|
output: `cli-${target}`,
|
|
targets: [target],
|
|
/**
|
|
* 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/**/*"),
|
|
],
|
|
});
|