Skip to content

Commit 57411af

Browse files
committed
feat: handle non-executable errors way better
1 parent 8abff31 commit 57411af

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

javascript/bin/bounty.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,27 @@ if (!fs.existsSync(binaryPath)) {
3232
process.exit(1);
3333
}
3434

35+
// Check executable permissions on Unix-like systems
36+
if (platform !== 'win32') {
37+
try {
38+
const stat = fs.statSync(binaryPath);
39+
// Check if file is executable for user
40+
if ((stat.mode & 0o100) === 0) {
41+
try {
42+
fs.chmodSync(binaryPath, 0o755);
43+
} catch (error) {
44+
console.error('\nError: Binary is not executable and could not set permissions automatically.');
45+
console.error(`Please run: sudo chmod +x "${binaryPath}"\n`);
46+
process.exit(1);
47+
}
48+
}
49+
} catch (error) {
50+
console.error('\nError: Could not check binary permissions.');
51+
console.error(`Please run: sudo chmod +x "${binaryPath}"\n`);
52+
process.exit(1);
53+
}
54+
}
55+
3556
// Execute the binary with the same arguments
3657
const result = spawnSync(binaryPath, process.argv.slice(2), {
3758
stdio: 'inherit'

javascript/package.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
"version": "1.0.0",
44
"description": "CLI tool for managing GitHub bounties",
55
"bin": {
6-
"bounty": "./bin/bounty.js",
7-
"@bountybot/cli": "./bin/bounty.js"
6+
"bounty": "./bin/bounty.js"
87
},
98
"scripts": {
109
"prepare": "node scripts/build.js",
1110
"build": "node scripts/build.js",
12-
"build:release": "node scripts/build.js --release"
13-
},
11+
"build:release": "node scripts/build.js --release",
12+
"postinstall": "node scripts/postinstall.js"
13+
},
1414
"files": [
1515
"bin",
1616
"scripts"
@@ -23,8 +23,10 @@
2323
"devDependencies": {
2424
"fs-extra": "^11.2.0"
2525
},
26+
"dependencies": {
27+
"fs-extra": "^11.2.0"
28+
},
2629
"publishConfig": {
27-
"access": "public",
28-
"preserveSymlinks": true
30+
"access": "public"
2931
}
3032
}

0 commit comments

Comments
 (0)