init commit
This commit is contained in:
20
build/create.js
Normal file
20
build/create.js
Normal file
@@ -0,0 +1,20 @@
|
||||
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;
|
||||
fs.writeFileSync(path.join(__dirname, `../data/holiday/${holidayId}.json`), JSON.stringify(template, null, 4));
|
14
build/generate.js
Normal file
14
build/generate.js
Normal file
@@ -0,0 +1,14 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
let order = fs.readFileSync(path.join(__dirname, '../data/order.json'), 'utf8');
|
||||
order = JSON.parse(order);
|
||||
|
||||
let holidayList = [];
|
||||
for (let holidayId of order) {
|
||||
let holiday = fs.readFileSync(path.join(__dirname, `../data/holiday/${holidayId}.json`), 'utf8');
|
||||
holiday = JSON.parse(holiday);
|
||||
holidayList.push(holiday);
|
||||
}
|
||||
fs.writeFileSync(path.join(__dirname, `../holiday.min.json`), JSON.stringify(holidayList));
|
||||
fs.writeFileSync(path.join(__dirname, `../holiday.json`), JSON.stringify(holidayList, null, 4));
|
Reference in New Issue
Block a user