Update compile_config.js

This commit is contained in:
syuilo 2026-01-05 18:55:31 +09:00
parent 9425de3ba6
commit 0ee286f02b
1 changed files with 14 additions and 5 deletions

View File

@ -17,7 +17,8 @@ const _filename = fileURLToPath(import.meta.url);
const _dirname = dirname(_filename);
const configDir = resolve(_dirname, '../../../.config');
const OUTPUT_PATH = resolve(_dirname, '../../../built/.config.json');
const OUTPUT_PATH1 = resolve(_dirname, '../../../built/.config.json');
const OUTPUT_PATH2 = resolve(_dirname, '../../../src-js/.config.json');
// TODO: yamlのパースに失敗したときのエラーハンドリング
@ -31,14 +32,22 @@ function yamlToJson(ymlPath) {
return;
}
console.log(`${ymlPath}${OUTPUT_PATH}`);
console.log(`${ymlPath}${OUTPUT_PATH1}`);
console.log(`${ymlPath}${OUTPUT_PATH2}`);
const yamlContent = fs.readFileSync(ymlPath, 'utf-8');
const jsonContent = yaml.load(yamlContent);
if (!fs.existsSync(dirname(OUTPUT_PATH))) {
fs.mkdirSync(dirname(OUTPUT_PATH), { recursive: true });
if (!fs.existsSync(dirname(OUTPUT_PATH1))) {
fs.mkdirSync(dirname(OUTPUT_PATH1), { recursive: true });
}
fs.writeFileSync(OUTPUT_PATH, JSON.stringify({
if (!fs.existsSync(dirname(OUTPUT_PATH2))) {
fs.mkdirSync(dirname(OUTPUT_PATH2), { recursive: true });
}
fs.writeFileSync(OUTPUT_PATH1, JSON.stringify({
'_NOTE_': 'This file is auto-generated from YAML file. DO NOT EDIT.',
...jsonContent,
}), 'utf-8');
fs.writeFileSync(OUTPUT_PATH2, JSON.stringify({
'_NOTE_': 'This file is auto-generated from YAML file. DO NOT EDIT.',
...jsonContent,
}), 'utf-8');