From 548bc4f5a59f215b552211cd1e77a605e138a505 Mon Sep 17 00:00:00 2001 From: Avris Date: Mon, 4 Oct 2021 23:43:56 +0200 Subject: [PATCH] #266 [calendar] generate banners - add --force argument --- server/calendar.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/calendar.js b/server/calendar.js index f2b8073d..92414366 100644 --- a/server/calendar.js +++ b/server/calendar.js @@ -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); } }