generated from nhcarrigan/template
20 lines
646 B
JavaScript
20 lines
646 B
JavaScript
import { readdir, readFile, writeFile } from "node:fs/promises";
|
|
import { join } from "node:path";
|
|
import { parse } from "yaml";
|
|
|
|
const files = await readdir(join(import.meta.dirname, "data"));
|
|
|
|
for (const file of files) {
|
|
if (!file.endsWith(".yml")) continue;
|
|
|
|
const name = file.split(".")[0];
|
|
if (name === undefined) {
|
|
continue;
|
|
} // Handled manually
|
|
const path = join(import.meta.dirname, "data", file);
|
|
const contents = await readFile(path, "utf-8");
|
|
|
|
const object = await parse(contents);
|
|
|
|
await writeFile(join(import.meta.dirname, "data", `${name}.json`), JSON.stringify(object, null, 2), "utf-8");
|
|
} |