@@ -40,22 +40,24 @@ const buildServerBinaryPackage = register("build:server:binary:package", async (
40
40
} ) ;
41
41
42
42
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.
44
47
const nexeDir = path . join ( os . homedir ( ) , ".nexe" ) ;
45
48
const targetBinaryName = `${ os . platform ( ) } -${ os . arch ( ) } -${ process . version . substr ( 1 ) } ` ;
46
49
const targetBinaryPath = path . join ( nexeDir , targetBinaryName ) ;
47
50
if ( ! fs . existsSync ( targetBinaryPath ) ) {
48
- /**
49
- * We create a binary with nexe
50
- * so we can compress it
51
- */
52
51
fse . mkdirpSync ( nexeDir ) ;
53
52
runner . cwd = nexeDir ;
54
53
await runner . execute ( "wget" , [ `https://github.com/nexe/nexe/releases/download/v3.0.0-beta.15/${ targetBinaryName } ` ] ) ;
55
54
await runner . execute ( "chmod" , [ "+x" , targetBinaryPath ] ) ;
56
55
}
56
+ // Compress with upx if it doesn't already look compressed.
57
57
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" ) ;
59
61
const upxFolder = path . join ( os . tmpdir ( ) , "upx" ) ;
60
62
const upxBinary = path . join ( upxFolder , "upx" ) ;
61
63
if ( ! fs . existsSync ( upxBinary ) ) {
0 commit comments