From 8497ab91573fda2b21d48789c25046c13c640e6b Mon Sep 17 00:00:00 2001 From: David Vegh Date: Mon, 26 Sep 2022 09:36:15 +0200 Subject: [PATCH] Fixed: stat writing, if last week stat is empty --- src/npmstat.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/npmstat.js b/src/npmstat.js index e2d77b5..c8f36d3 100644 --- a/src/npmstat.js +++ b/src/npmstat.js @@ -257,6 +257,17 @@ class WriteNpmStat { const stats = this.getLastWeekNpmStat(); stats.then((stats) => { const day = StatDate.formatStart(new Date()); + if (Object.keys(stats).length === 0) { + const statKey = day.concat("_", "-"); + const statValue = []; + statValue.push(day); + if (this.#writePackageName) { + statValue.push(this.#packageName); + } + statValue.push("-"); + statValue.push(0); + stats[statKey] = statValue; + } const grouped = this.#groupStats( lastWeek, stats,