import type { ChildProcess, SpawnOptions } from "node:child_process"; import { EventEmitter } from "node:events"; import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import { PassThrough } from "node:stream"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
function createMockChildProcess(): MockChildProcess { const child = new EventEmitter() as MockChildProcess;
child.stdin = new PassThrough();
child.stdout = new PassThrough();
child.stderr = new PassThrough();
child.kill = vi.fn(); return child;
}
function mockSuccessfulSpawnCalls(times = 1) {
let chain = spawnMock; for (let i = 0; i < times; i += 1) {
chain = chain.mockImplementationOnce(
(_command: string, _args: readonly string[], _options: SpawnOptions): ChildProcess => { const child = createMockChildProcess();
process.nextTick(() => {
child.emit("close", 0);
}); return child as unknown as ChildProcess;
},
);
}
}
let runSshSandboxCommand: typeofimport("./ssh.js").runSshSandboxCommand;
let uploadDirectoryToSshTarget: typeofimport("./ssh.js").uploadDirectoryToSshTarget;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.