Skip to content

Commit d70a833

Browse files
fix: improve Bun detection using which command (#11)
Replace hardcoded path checks with a more reliable method using the 'which' command to detect Bun installation. This will properly detect Bun installed in non-standard locations like ~/.bun/bin/. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude <[email protected]>
1 parent 4b524db commit d70a833

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/commands/init.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,17 @@ This command sets up basic Claude Code hooks in your project:
4242
console.log(chalk.blue.bold('\n🪝 Claude Hooks Setup\n'))
4343

4444
// Check if Bun is installed
45-
try {
46-
await fs.access('/usr/bin/bun')
47-
} catch {
48-
try {
49-
await fs.access('/usr/local/bin/bun')
50-
} catch {
51-
console.log(chalk.yellow('⚠️ Warning: Bun is not installed on your system'))
52-
console.log(chalk.gray(' Bun is required to run Claude hooks'))
53-
console.log(chalk.gray(' Install it with: curl -fsSL https://bun.sh/install | bash\n'))
54-
}
45+
const {spawn} = await import('node:child_process')
46+
const checkBun = await new Promise<boolean>((resolve) => {
47+
const child = spawn('which', ['bun'], {shell: false})
48+
child.on('error', () => resolve(false))
49+
child.on('exit', (code) => resolve(code === 0))
50+
})
51+
52+
if (!checkBun) {
53+
console.log(chalk.yellow('⚠️ Warning: Bun is not installed on your system'))
54+
console.log(chalk.gray(' Bun is required to run Claude hooks'))
55+
console.log(chalk.gray(' Install it with: curl -fsSL https://bun.sh/install | bash\n'))
5556
}
5657

5758
// Check if hooks already exist

0 commit comments

Comments
 (0)