BililiveRecorder/config_gen/generators/doc.ts
2022-06-10 16:34:25 +08:00

27 lines
730 B
TypeScript

import { ConfigEntry } from "../types"
import { statSync, writeFileSync } from "fs";
import { resolve } from "path"
import { data } from "../data";
import { trimEnd } from "../utils";
export default function doc(path: string): void {
if (!statSync(resolve(path, 'mkdocs.yml'))) {
console.error('Check your path');
return;
}
if (!statSync(resolve(path, 'docs/user/settings.md'))) {
console.error('Check your path');
return;
}
const targetPath = resolve(path, 'data/brec_settings.json')
const text = buildJson(data)
writeFileSync(targetPath, text, { encoding: 'utf8' });
}
function buildJson(data: ConfigEntry[]): string {
return JSON.stringify(data, null, 2);
}