31 lines
1.0 KiB
TypeScript
31 lines
1.0 KiB
TypeScript
// Test support: the current user's IDs and a fresh temporary directory, plus
|
|
// the source helpers that the repository-level tests in tests/ need. Those
|
|
// tests sit outside src/ and reach it only through the `#testing` alias.
|
|
import { mkdtemp } from "node:fs/promises";
|
|
import { tmpdir } from "node:os";
|
|
import { join } from "node:path";
|
|
import process from "node:process";
|
|
|
|
export function currentUid(): number {
|
|
return process.getuid?.() ?? -1;
|
|
}
|
|
|
|
export function currentGid(): number {
|
|
return process.getgid?.() ?? -1;
|
|
}
|
|
|
|
// The isolation tests switch UIDs, which only root may do.
|
|
export const IS_ROOT: boolean = currentUid() === 0;
|
|
|
|
// Symlinks and POSIX modes, as these tests use them, need a Unix host.
|
|
export const IS_WINDOWS: boolean = process.platform === "win32";
|
|
|
|
export function makeTempDir(): Promise<string> {
|
|
return mkdtemp(join(tmpdir(), "bot-agents-test-"));
|
|
}
|
|
|
|
export { output } from "./command.ts";
|
|
export { isNotFound } from "./errors.ts";
|
|
export { isMapping } from "./json.ts";
|
|
export type { JsonObject } from "./json.ts";
|