fix: compile_config.js should skip when YAML file not found instead of failing
Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
This commit is contained in:
parent
010b540679
commit
85e9612506
|
|
@ -27,18 +27,17 @@ const OUTPUT_PATH = resolve(configDir, '.config.json');
|
||||||
*/
|
*/
|
||||||
function yamlToJson(ymlPath) {
|
function yamlToJson(ymlPath) {
|
||||||
if (!fs.existsSync(ymlPath)) {
|
if (!fs.existsSync(ymlPath)) {
|
||||||
console.warn(`YAML file not found: ${ymlPath}`);
|
console.log(`skipped: ${ymlPath} is not found`);
|
||||||
process.exit(1);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`${ymlPath} → ${OUTPUT_PATH}`);
|
|
||||||
|
|
||||||
const yamlContent = fs.readFileSync(ymlPath, 'utf-8');
|
const yamlContent = fs.readFileSync(ymlPath, 'utf-8');
|
||||||
const jsonContent = yaml.load(yamlContent);
|
const jsonContent = yaml.load(yamlContent);
|
||||||
fs.writeFileSync(OUTPUT_PATH, JSON.stringify({
|
fs.writeFileSync(OUTPUT_PATH, JSON.stringify({
|
||||||
'_NOTE_': 'This file is auto-generated from YAML file. DO NOT EDIT.',
|
'_NOTE_': 'This file is auto-generated from YAML file. DO NOT EDIT.',
|
||||||
...jsonContent,
|
...jsonContent,
|
||||||
}), 'utf-8');
|
}), 'utf-8');
|
||||||
|
console.log(`✓ ${ymlPath} → ${OUTPUT_PATH}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (process.env.MISSKEY_CONFIG_YML) {
|
if (process.env.MISSKEY_CONFIG_YML) {
|
||||||
|
|
@ -48,4 +47,4 @@ if (process.env.MISSKEY_CONFIG_YML) {
|
||||||
yamlToJson(resolve(configDir, process.env.NODE_ENV === 'test' ? 'test.yml' : 'default.yml'));
|
yamlToJson(resolve(configDir, process.env.NODE_ENV === 'test' ? 'test.yml' : 'default.yml'));
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('Configuration compiled ✓');
|
console.log('Configuration compiled');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue