2019-03-27 01:01:25 +07:00
|
|
|
import { Binary } from "@coder/nbin";
|
|
|
|
import * as fs from "fs";
|
|
|
|
import * as os from "os";
|
|
|
|
import * as path from "path";
|
2019-04-26 20:56:14 +07:00
|
|
|
import { platform } from "../../../build/platform";
|
2019-03-27 01:01:25 +07:00
|
|
|
|
2019-04-26 20:56:14 +07:00
|
|
|
const target = `${platform()}-${os.arch()}`;
|
2019-03-27 01:01:25 +07:00
|
|
|
const rootDir = path.join(__dirname, "..");
|
|
|
|
const bin = new Binary({
|
|
|
|
mainFile: path.join(rootDir, "out", "cli.js"),
|
2019-04-26 20:56:14 +07:00
|
|
|
target: platform() === "darwin" ? "darwin" : platform() === "musl" ? "alpine" : "linux",
|
2019-03-27 01:01:25 +07:00
|
|
|
});
|
|
|
|
bin.writeFiles(path.join(rootDir, "build", "**"));
|
|
|
|
bin.writeFiles(path.join(rootDir, "out", "**"));
|
2019-04-16 07:48:12 +07:00
|
|
|
[
|
|
|
|
// Native modules. These are marked as externals in the webpack config.
|
|
|
|
"spdlog",
|
|
|
|
"node-pty",
|
|
|
|
|
|
|
|
// These are spdlog's dependencies.
|
|
|
|
"mkdirp", "bindings",
|
|
|
|
].forEach((name) => {
|
|
|
|
bin.writeModule(path.join(__dirname, "../../../node_modules", name));
|
|
|
|
});
|
2019-03-27 01:01:25 +07:00
|
|
|
bin.build().then((binaryData) => {
|
|
|
|
const outputPath = path.join(__dirname, "..", `cli-${target}`);
|
|
|
|
fs.writeFileSync(outputPath, binaryData);
|
|
|
|
fs.chmodSync(outputPath, "755");
|
|
|
|
}).catch((ex) => {
|
|
|
|
// tslint:disable-next-line:no-console
|
|
|
|
console.error(ex);
|
|
|
|
process.exit(1);
|
|
|
|
});
|