fix: use verifyFormatting in CLI path for consistent line-ending normalization

This commit is contained in:
Johannes
2026-04-28 13:50:09 +02:00
parent 91e2d5c196
commit 53db5e07d6
+7 -8
View File
@@ -115,18 +115,17 @@ if (import.meta.main) {
for (const file of files) {
const absolutePath = path.resolve(file);
const text = fs.readFileSync(absolutePath, 'utf8');
const formatted = format(absolutePath, text);
if (text !== formatted) {
if (replace) {
if (replace) {
const formatted = format(absolutePath, text);
if (text !== formatted) {
fs.writeFileSync(absolutePath, formatted, 'utf8');
console.log(`Formatted ${file}`);
} else if (verify) {
console.error(`File not formatted. Run the 'Format Document' command to fix it: ${file}`);
errorCount++;
} else {
console.error(`File not formatted: ${file}`);
}
}
if (verify && !verifyFormatting(absolutePath, replace ? fs.readFileSync(absolutePath, 'utf8') : text)) {
console.error(`File not formatted. Run the 'Format Document' command to fix it: ${file}`);
errorCount++;
}
}
if (errorCount > 0) {
process.exit(1);