class StubSetupProcessHandle {
    lineHandler = null;
    exitHandler = null;
    killed = false;
    writtenLines = [];
    pid = 4242;
    onLine(handler) {
        this.lineHandler = handler;
    }
    onExit(handler) {
        this.exitHandler = handler;
    }
    writeLine(line) {
        this.writtenLines.push(line);
    }
    kill() {
        this.killed = true;
    }
    pushLine(line) {
        this.lineHandler?.(line);
    }
    pushExit(code) {
        this.exitHandler?.(code);
    }
}
export class StubSetupProcessGateway {
    handle = null;
    spawnCount = 0;
    lastSpawnOptions = null;
    spawn(options) {
        this.spawnCount += 1;
        this.lastSpawnOptions = options ?? null;
        this.handle = new StubSetupProcessHandle();
        return this.handle;
    }
    emitLine(line) {
        this.handle?.pushLine(line);
    }
    exit(code) {
        this.handle?.pushExit(code);
    }
    get killed() {
        return this.handle?.killed ?? false;
    }
    get writtenLines() {
        return this.handle?.writtenLines ?? [];
    }
    get lastWrittenLine() {
        const lines = this.writtenLines;
        return lines.length > 0 ? lines[lines.length - 1] : null;
    }
}
//# sourceMappingURL=setupProcess.stub.js.map