feat(repo): add yaml validation pre-commit hook
This commit is contained in:
26
scripts/lint-yaml.js
Executable file
26
scripts/lint-yaml.js
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import fs from "node:fs";
|
||||
import yaml from "js-yaml";
|
||||
|
||||
const files = process.argv.slice(2);
|
||||
let hasError = false;
|
||||
|
||||
if (files.length === 0) {
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
for (const file of files) {
|
||||
try {
|
||||
const content = fs.readFileSync(file, "utf8");
|
||||
yaml.load(content);
|
||||
console.log(`✓ ${file} is valid`);
|
||||
} catch (e) {
|
||||
console.error(`✗ ${file} is invalid: ${e.message}`);
|
||||
hasError = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasError) {
|
||||
process.exit(1);
|
||||
}
|
||||
Reference in New Issue
Block a user