import { spawn } from 'node:child_process';
function defaultGitRunner() {
    return async (command) => new Promise((resolve, reject) => {
        const child = spawn('git', command.args, { cwd: command.cwd });
        let stdout = '';
        let stderr = '';
        child.stdout?.on('data', chunk => {
            stdout += chunk.toString();
        });
        child.stderr?.on('data', chunk => {
            stderr += chunk.toString();
        });
        child.on('error', reject);
        child.on('close', code => {
            resolve({ stdout, stderr, exitCode: code ?? -1 });
        });
    });
}
export class GitCommandCliGateway {
    runner;
    constructor(runner = defaultGitRunner()) {
        this.runner = runner;
    }
    async execute(command) {
        return this.runner(command);
    }
}
//# sourceMappingURL=gitCommand.cli.gateway.js.map