@softr/sdk
Version:
The SDK for building Softr apps on TanStack Start. It lets an app interact with Softr: auth, datasources, workflows and integrations.
22 lines (20 loc) • 617 B
JavaScript
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
import path from "node:path";
//#region src/codegen/write-if-changed.ts
/** Returns whether it had to write. */
function writeIfChanged(file, content) {
if (readOrNull(file) === content) return false;
mkdirSync(path.dirname(file), { recursive: true });
writeFileSync(file, content, "utf8");
return true;
}
function readOrNull(file) {
try {
return readFileSync(file, "utf8");
} catch (error) {
if (error instanceof Error && "code" in error && error.code === "ENOENT") return null;
throw error;
}
}
//#endregion
export { writeIfChanged };