1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee
holiday/build/create.js

26 lines
954 B
JavaScript
Raw Permalink Normal View History

2022-11-20 00:01:25 +08:00
const fs = require('fs');
const path = require('path');
if (process.argv.length < 3) {
console.log("未传入节日Id参数");
return;
}
let holidayId = process.argv.slice(2).join(" ");
console.log(`holidayId: ${holidayId}`);
let order = fs.readFileSync(path.join(__dirname, '../data/order.json'), 'utf8');
order = JSON.parse(order);
order.push(holidayId);
fs.writeFileSync(path.join(__dirname, `../data/order.json`), JSON.stringify(order, null, 4));
let template = fs.readFileSync(path.join(__dirname, '../data/template.json'), 'utf8');
template = JSON.parse(template);
template['id'] = holidayId;
template['englishName'] = holidayId;
2022-11-20 00:23:20 +08:00
template['skip'] = false;
template['subFestival'] = [];
template['commemorator'] = [];
2022-11-20 00:30:47 +08:00
template['nationalCulturalHeritage'] = '';
template['worldCulturalHeritage'] = '';
2022-11-20 00:01:25 +08:00
fs.writeFileSync(path.join(__dirname, `../data/holiday/${holidayId}.json`), JSON.stringify(template, null, 4));