"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.spawn = void 0;
const ignore_closed_input_stream_1 = require("./ignore-closed-input-stream");
const git_environment_1 = require("./git-environment");
const child_process_1 = require("child_process");
/**
 * Execute a command and interact with the process outputs directly.
 *
 * The returned promise will reject when the git executable fails to launch,
 * in which case the thrown Error will have a string `code` property. See
 * `errors.ts` for some of the known error codes.
 */
function spawn(args, path, opts) {
    const { env, gitLocation } = (0, git_environment_1.setupEnvironment)(opts?.env ?? {});
    const spawnedProcess = (0, child_process_1.spawn)(gitLocation, args, { env, cwd: path });
    (0, ignore_closed_input_stream_1.ignoreClosedInputStream)(spawnedProcess);
    return spawnedProcess;
}
exports.spawn = spawn;
//# sourceMappingURL=spawn.js.map