Files
claude-code-haha/bin/claude-haha
Relakkes Yang f332057b88 fix(windows): handle tab edits and missing Git Bash #1168
Preserve file indentation across tabs and spaces, route command tools to an available Windows shell, and make the source CLI launcher cross-platform.
2026-08-02 16:45:19 +08:00

51 lines
1.5 KiB
TypeScript
Executable File

#!/usr/bin/env -S bun --no-env-file
import { existsSync } from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
const rootDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
const callerDir = process.env.CALLER_DIR || process.cwd()
const skipDotenv = process.env.CC_HAHA_SKIP_DOTENV === '1'
const rootEnvPath = path.join(rootDir, '.env')
const envFileArgs =
!skipDotenv && existsSync(rootEnvPath)
? [`--env-file=${rootEnvPath}`]
: ['--no-env-file']
const entrypoint =
process.env.CLAUDE_CODE_FORCE_RECOVERY_CLI === '1'
? path.join(rootDir, 'src', 'localRecoveryCli.ts')
: path.join(rootDir, 'src', 'entrypoints', 'cli.tsx')
const command = [
process.execPath,
'--feature=TRANSCRIPT_CLASSIFIER',
...envFileArgs,
entrypoint,
...process.argv.slice(2),
]
const child = Bun.spawn(command, {
cwd: rootDir,
env: { ...process.env, CALLER_DIR: callerDir },
stdin: 'inherit',
stdout: 'inherit',
stderr: 'inherit',
})
const forwardSignal = (signal: NodeJS.Signals) => {
try {
child.kill(signal)
} catch {
// The child may have completed between the signal and this handler.
}
}
const forwardInterrupt = () => forwardSignal('SIGINT')
const forwardTerminate = () => forwardSignal('SIGTERM')
process.on('SIGINT', forwardInterrupt)
process.on('SIGTERM', forwardTerminate)
const exitCode = await child.exited
process.off('SIGINT', forwardInterrupt)
process.off('SIGTERM', forwardTerminate)
process.exit(exitCode)