diff --git a/hooks/hooks.json b/hooks/hooks.json index aa51892..cc49805 100644 --- a/hooks/hooks.json +++ b/hooks/hooks.json @@ -17,12 +17,12 @@ "hooks": [ { "type": "command", - "command": "bunx @pleaseai/code format --stdin", + "command": "bun $CLAUDE_PLUGIN_ROOT/hooks/scripts/code-runner.ts format --stdin", "timeout": 10 }, { "type": "command", - "command": "bunx @pleaseai/code lsp --stdin", + "command": "bun $CLAUDE_PLUGIN_ROOT/hooks/scripts/code-runner.ts lsp --stdin", "timeout": 10 } ] diff --git a/hooks/scripts/code-runner.ts b/hooks/scripts/code-runner.ts new file mode 100644 index 0000000..409d115 --- /dev/null +++ b/hooks/scripts/code-runner.ts @@ -0,0 +1,23 @@ +import { spawnSync } from 'node:child_process' +import process from 'node:process' +import manifest from '../../.release-please-manifest.json' with { type: 'json' } + +const version = manifest['packages/code'] +if (!version) { + console.error( + 'Error: Could not find version for \'packages/code\' in .release-please-manifest.json', + ) + process.exit(1) +} + +const args = process.argv.slice(2) +const result = spawnSync('bunx', [`@pleaseai/code@${version}`, ...args], { + stdio: 'inherit', +}) + +if (result.error) { + console.error('Error: Failed to spawn bunx command.', result.error) + process.exit(1) +} + +process.exit(result.status ?? 1)