1
+ const fs = require ( 'fs-extra' ) ;
2
+ const path = require ( 'path' ) ;
3
+
4
+ // Get the bin directory relative to this script
5
+ const binDir = path . join ( __dirname , '../bin' ) ;
6
+
7
+ // Platform configurations (same as build.js)
8
+ const platforms = [
9
+ {
10
+ target : 'x86_64-unknown-linux-gnu' ,
11
+ binaryName : 'bounty-x86_64-unknown-linux-gnu' ,
12
+ sourceFile : 'bounty'
13
+ } ,
14
+ {
15
+ target : 'x86_64-apple-darwin' ,
16
+ binaryName : 'bounty-x86_64-apple-darwin' ,
17
+ sourceFile : 'bounty'
18
+ } ,
19
+ {
20
+ target : 'aarch64-apple-darwin' ,
21
+ binaryName : 'bounty-aarch64-apple-darwin' ,
22
+ sourceFile : 'bounty'
23
+ } ,
24
+ {
25
+ target : 'x86_64-pc-windows-msvc' ,
26
+ binaryName : 'bounty-x86_64-pc-windows-msvc.exe' ,
27
+ sourceFile : 'bounty.exe'
28
+ }
29
+ ] ;
30
+
31
+ // Only run chmod on Unix-like systems
32
+ if ( process . platform !== 'win32' ) {
33
+ console . log ( 'Attempting to set executable permissions on binaries...' ) ;
34
+
35
+ try {
36
+ // Set permissions on the wrapper script
37
+ const wrapperPath = path . join ( binDir , 'bounty.js' ) ;
38
+ if ( fs . existsSync ( wrapperPath ) ) {
39
+ fs . chmodSync ( wrapperPath , 0o755 ) ;
40
+ }
41
+
42
+ // Set permissions on all platform binaries
43
+ platforms . forEach ( platform => {
44
+ const binaryPath = path . join ( binDir , platform . binaryName ) ;
45
+ if ( fs . existsSync ( binaryPath ) ) {
46
+ try {
47
+ fs . chmodSync ( binaryPath , 0o755 ) ;
48
+ console . log ( `Set permissions for ${ platform . binaryName } ` ) ;
49
+ } catch ( err ) {
50
+ console . log ( `Note: Could not set permissions for ${ platform . binaryName } - this is OK` ) ;
51
+ }
52
+ }
53
+ } ) ;
54
+ } catch ( err ) {
55
+ console . log ( 'Note: Could not set some executable permissions during install - this is OK' ) ;
56
+ }
57
+ } else {
58
+ console . log ( 'Skipping permission setting on Windows' ) ;
59
+ }
0 commit comments