Files
alrahma_sunday_school_api/tools/normalize_model_timestamps_indent.mjs
2026-04-23 00:04:35 -04:00

25 lines
748 B
JavaScript

/**
* One-off / utility: normalize `public $timestamps` to 4-space class-body indent.
*/
import fs from "fs";
import path from "path";
import { fileURLToPath } from "url";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const modelsDir = path.join(__dirname, "..", "app", "Models");
let changed = 0;
for (const f of fs.readdirSync(modelsDir).filter((x) => x.endsWith(".php"))) {
const fp = path.join(modelsDir, f);
let c = fs.readFileSync(fp, "utf8");
const n = c.replace(
/^(\s+)public \$timestamps = (.+)$/gm,
(_, __, rest) => ` public $timestamps = ${rest}`
);
if (n !== c) {
fs.writeFileSync(fp, n);
changed++;
}
}
console.log(`normalize_model_timestamps_indent: updated ${changed} file(s)`);