#266 [calendar] generate banners - add --force argument

This commit is contained in:
Avris 2021-10-04 23:43:56 +02:00
parent ab3021b05e
commit 548bc4f5a5
1 changed files with 4 additions and 2 deletions

View File

@ -12,6 +12,8 @@ const config = loadSuml('config');
const dir = `${__dirname}/../static/calendar`;
const force = process.argv[2] === '-f' || process.argv[2] === '--force'
const shoot = async (url, filename) => {
const pr = new Pageres({
delay: 3,
@ -54,11 +56,11 @@ const dumpNameDays = async () => {
for (let day in current) {
if (!current.hasOwnProperty(day)) { continue; }
const year = day.substring(0, 4);
if (current[day] !== prev[day] || !fs.existsSync(`${dir}/${day}.png`)) {
if (current[day] !== prev[day] || !fs.existsSync(`${dir}/${day}.png`) || force) {
await shoot(`/${config.calendar.route}/${day}?layout=basic`, `${day}`);
changedYears.add(year);
}
if (!fs.existsSync(`${dir}/${year}-overview.png`) || !fs.existsSync(`${dir}/${year}-labels.png`)) {
if (!fs.existsSync(`${dir}/${year}-overview.png`) || !fs.existsSync(`${dir}/${year}-labels.png`) || force) {
changedYears.add(year);
}
}