Skip to content

Commit 8bab787

Browse files
committed
Move upx compression behind an env flag
1 parent 3e9d86e commit 8bab787

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

build/tasks.ts

+8-6
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,24 @@ const buildServerBinaryPackage = register("build:server:binary:package", async (
4040
});
4141

4242
const dependencyNexeBinary = register("dependency:nexe", async (runner) => {
43-
if (os.platform() === "linux") {
43+
if (os.platform() === "linux" && process.env.COMPRESS === "true") {
44+
// Download the nexe binary so we can compress it before nexe runs. If we
45+
// don't want compression we don't need to do anything since nexe will take
46+
// care of getting the binary.
4447
const nexeDir = path.join(os.homedir(), ".nexe");
4548
const targetBinaryName = `${os.platform()}-${os.arch()}-${process.version.substr(1)}`;
4649
const targetBinaryPath = path.join(nexeDir, targetBinaryName);
4750
if (!fs.existsSync(targetBinaryPath)) {
48-
/**
49-
* We create a binary with nexe
50-
* so we can compress it
51-
*/
5251
fse.mkdirpSync(nexeDir);
5352
runner.cwd = nexeDir;
5453
await runner.execute("wget", [`https://github.com/nexe/nexe/releases/download/v3.0.0-beta.15/${targetBinaryName}`]);
5554
await runner.execute("chmod", ["+x", targetBinaryPath]);
5655
}
56+
// Compress with upx if it doesn't already look compressed.
5757
if (fs.statSync(targetBinaryPath).size >= 20000000) {
58-
// Compress w/ upx
58+
// It needs to be executable for upx to work, which it might not be if
59+
// nexe downloaded it.
60+
fs.chmodSync(targetBinaryPath, "755");
5961
const upxFolder = path.join(os.tmpdir(), "upx");
6062
const upxBinary = path.join(upxFolder, "upx");
6163
if (!fs.existsSync(upxBinary)) {

0 commit comments

Comments
 (0)