feat(cli): add Bun runtime support for ripgrep and CLI spawning

Replace hardcoded 'node' commands with process.execPath to support
Bun runtime alongside Node.js. Add runtime detection and entrypoint
resolution for Bun. Update documentation to reflect multi-runtime support.
This commit is contained in:
weishu
2025-12-20 16:03:51 +08:00
parent 05c2cbb724
commit 80725a2d34
3 changed files with 37 additions and 23 deletions
+4 -10
View File
@@ -3,8 +3,8 @@
*/
import { spawn } from 'child_process';
import { projectPath } from '@/projectPath';
import { join, resolve } from 'path';
import { projectPath } from '@/projectPath';
export interface RipgrepResult {
exitCode: number
@@ -16,16 +16,10 @@ export interface RipgrepOptions {
cwd?: string
}
/**
* Run ripgrep with the given arguments
* @param args - Array of command line arguments to pass to ripgrep
* @param options - Options for ripgrep execution
* @returns Promise with exit code, stdout and stderr
*/
export function run(args: string[], options?: RipgrepOptions): Promise<RipgrepResult> {
const RUNNER_PATH = resolve(join(projectPath(), 'scripts', 'ripgrep_launcher.cjs'));
const runnerPath = resolve(join(projectPath(), 'scripts', 'ripgrep_launcher.cjs'));
return new Promise((resolve, reject) => {
const child = spawn('node', [RUNNER_PATH, JSON.stringify(args)], {
const child = spawn(process.execPath, [runnerPath, JSON.stringify(args)], {
stdio: ['pipe', 'pipe', 'pipe'],
cwd: options?.cwd
});
@@ -53,4 +47,4 @@ export function run(args: string[], options?: RipgrepOptions): Promise<RipgrepRe
reject(err);
});
});
}
}