mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-11-01 05:48:18 +00:00
Run the CLI subprocess suites and benchmark tools as native TypeScript with node:test, and move them under test/e2e-cli. Update CI and Compose runners, run local smoke tests on Linux, macOS, and Windows, and collect source-mapped CLI coverage with c8.
21 lines
726 B
TypeScript
21 lines
726 B
TypeScript
import { mkdtemp, rm } from "node:fs/promises";
|
|
import { tmpdir } from "node:os";
|
|
import { join } from "node:path";
|
|
|
|
/** A temporary directory which is removed when its `await using` scope ends. */
|
|
export class TempDir implements AsyncDisposable {
|
|
readonly path: string;
|
|
private constructor(path: string) {
|
|
this.path = path;
|
|
}
|
|
static async create(prefix = "livesync-node-test"): Promise<TempDir> {
|
|
return new TempDir(await mkdtemp(join(tmpdir(), `${prefix}.`)));
|
|
}
|
|
join(...parts: string[]): string {
|
|
return join(this.path, ...parts);
|
|
}
|
|
async [Symbol.asyncDispose](): Promise<void> {
|
|
await rm(this.path, { recursive: true, force: true }).catch(() => {});
|
|
}
|
|
}
|