Files
openclaw/scripts/lib/generated-output-utils.mjs
2026-06-18 16:29:56 +08:00

26 lines
734 B
JavaScript

// Shared write/check/report helpers for generated repository files.
import path from "node:path";
import { writeTextFileIfChanged } from "../runtime-postbuild-shared.mjs";
import { readIfExists } from "./bundled-plugin-source-utils.mjs";
/** Write generated output unless check mode only needs stale-state metadata. */
export function writeGeneratedOutput(params) {
const outputPath = path.resolve(params.repoRoot, params.outputPath);
const current = readIfExists(outputPath);
const changed = current !== params.next;
if (params.check) {
return {
changed,
wrote: false,
outputPath,
};
}
return {
changed,
wrote: writeTextFileIfChanged(outputPath, params.next),
outputPath,
};
}