mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-06 06:41:56 +00:00
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:
@@ -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);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user