Archived
1
0

Move upx compression behind an env flag

This commit is contained in:
Asher 2019-03-08 12:00:47 -06:00
parent 3e9d86ee91
commit 8bab787804
No known key found for this signature in database
GPG Key ID: 7BB4BA9C783D2BBC

View File

@ -40,22 +40,24 @@ const buildServerBinaryPackage = register("build:server:binary:package", async (
});
const dependencyNexeBinary = register("dependency:nexe", async (runner) => {
if (os.platform() === "linux") {
if (os.platform() === "linux" && process.env.COMPRESS === "true") {
// Download the nexe binary so we can compress it before nexe runs. If we
// don't want compression we don't need to do anything since nexe will take
// care of getting the binary.
const nexeDir = path.join(os.homedir(), ".nexe");
const targetBinaryName = `${os.platform()}-${os.arch()}-${process.version.substr(1)}`;
const targetBinaryPath = path.join(nexeDir, targetBinaryName);
if (!fs.existsSync(targetBinaryPath)) {
/**
* We create a binary with nexe
* so we can compress it
*/
fse.mkdirpSync(nexeDir);
runner.cwd = nexeDir;
await runner.execute("wget", [`https://github.com/nexe/nexe/releases/download/v3.0.0-beta.15/${targetBinaryName}`]);
await runner.execute("chmod", ["+x", targetBinaryPath]);
}
// Compress with upx if it doesn't already look compressed.
if (fs.statSync(targetBinaryPath).size >= 20000000) {
// Compress w/ upx
// It needs to be executable for upx to work, which it might not be if
// nexe downloaded it.
fs.chmodSync(targetBinaryPath, "755");
const upxFolder = path.join(os.tmpdir(), "upx");
const upxBinary = path.join(upxFolder, "upx");
if (!fs.existsSync(upxBinary)) {