From 4bcbb39b955f1125120f1675ad73492a5e5442ce Mon Sep 17 00:00:00 2001 From: Determinant Date: Mon, 9 Sep 2024 16:44:44 -0700 Subject: group the current version charts with a folder --- app.mjs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app.mjs b/app.mjs index f590ffc..fa7ace7 100755 --- a/app.mjs +++ b/app.mjs @@ -238,7 +238,11 @@ for (let r of res) { continue; } const date = cur.date.format("YYYY-MM-DD"); - const file = `${cur.unzip ? zip_path : chart_path}/${r.prefix}-${region.toLowerCase()}-${date}.${cur.unzip ? "zip" : "pdf"}`; + const dir = `${cur.unzip ? zip_path : chart_path}/${date}`; + try { + await fs.mkdir(dir); + } catch (_) {} + const file = `${dir}/${r.prefix}-${region.toLowerCase()}.${cur.unzip ? "zip" : "pdf"}`; const fileExists = (path) => fs.stat(path).then( () => true, @@ -257,7 +261,7 @@ for (let r of res) { await decompress(file, "./", { filter: (f) => cur.unzip[f.path] != null, map: (f) => { - f.path = `${chart_path}/${r.prefix}-${region.toLowerCase()}-${date}${cur.unzip[f.path]}`; + f.path = `${chart_path}/${date}/${r.prefix}-${region.toLowerCase()}${cur.unzip[f.path]}`; return f; }, }); -- cgit v1.2.3-70-g09d2