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