#!/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);
}
