complete framework remediation validation
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { readdirSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import prettier from "prettier";
|
||||
|
||||
const uiRoot = join(import.meta.dirname, "..", "packages", "ui");
|
||||
const componentsDir = join(uiRoot, "components");
|
||||
@@ -11,17 +12,20 @@ function normalizeNewlines(source) {
|
||||
return source.replace(/\r\n?/g, "\n");
|
||||
}
|
||||
|
||||
async function writeFormatted(path, source) {
|
||||
async function writeFormatted(path, source, parser) {
|
||||
const formatted = parser
|
||||
? await prettier.format(source, { parser, printWidth: 100, endOfLine: "lf" })
|
||||
: source;
|
||||
const current = readFileSync(path, "utf8");
|
||||
|
||||
// Do not rewrite a generated file when only its working-tree line endings
|
||||
// differ. This keeps release verification clean on Windows CRLF checkouts
|
||||
// while still rewriting files whose generated content is genuinely stale.
|
||||
if (normalizeNewlines(current) === normalizeNewlines(source)) {
|
||||
if (normalizeNewlines(current) === normalizeNewlines(formatted)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
writeFileSync(path, source);
|
||||
writeFileSync(path, formatted);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user