fix: handle bun child_process interop

Resolve execFile from named or default child_process exports so macOS Bun can load gitService in tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
David Kaya
2026-03-26 00:34:44 +01:00
co-authored by Copilot
parent d9f3f5302a
commit 66c129f8b9
2 changed files with 43 additions and 3 deletions
+24 -2
View File
@@ -1,10 +1,32 @@
import childProcess, { type ExecFileException } from 'node:child_process';
import * as childProcessModule from 'node:child_process';
import { promisify } from 'node:util';
import type { ProjectGitChangeSummary, ProjectGitCommitSummary, ProjectGitContext } from '@shared/domain/project';
import { nowIso } from '@shared/utils/ids';
const execFileAsync = promisify(childProcess.execFile);
type ExecFileException = import('node:child_process').ExecFileException;
type ChildProcessModuleLike = {
readonly execFile?: typeof childProcessModule.execFile;
readonly default?: {
readonly execFile?: typeof childProcessModule.execFile;
};
};
export function resolveExecFileForInterop(
module: ChildProcessModuleLike,
): typeof childProcessModule.execFile {
const execFile = module.execFile ?? module.default?.execFile;
if (typeof execFile !== 'function') {
throw new Error('node:child_process execFile is unavailable.');
}
return execFile;
}
const execFileAsync = promisify(
resolveExecFileForInterop(childProcessModule as ChildProcessModuleLike),
);
const GIT_TIMEOUT_MS = 5_000;
type GitCommandRunner = (projectPath: string, args: string[]) => Promise<string>;