mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
7595d6f432
* test(tooling): remove helper replays * refactor(tooling): inline fixture json serialization
25 lines
661 B
JavaScript
25 lines
661 B
JavaScript
// Common file/assertion helpers for E2E fixture writers.
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
|
|
export const readJson = (file) => JSON.parse(fs.readFileSync(file, "utf8"));
|
|
|
|
export const write = (file, contents) => {
|
|
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
fs.writeFileSync(file, contents);
|
|
};
|
|
export const writeJson = (file, value) => write(file, `${JSON.stringify(value, null, 2)}\n`);
|
|
|
|
export const requireArg = (value, name) => {
|
|
if (!value) {
|
|
throw new Error(`${name} is required`);
|
|
}
|
|
return value;
|
|
};
|
|
|
|
export const assert = (condition, message) => {
|
|
if (!condition) {
|
|
throw new Error(message);
|
|
}
|
|
};
|