Skip to content

Commit 901877f

Browse files
authored
Merge pull request #61 from veghdev/lastweek-empty
Fixed: stat writing, if last week stat is empty
2 parents 47e680f + 8497ab9 commit 901877f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/npmstat.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,17 @@ class WriteNpmStat {
257257
const stats = this.getLastWeekNpmStat();
258258
stats.then((stats) => {
259259
const day = StatDate.formatStart(new Date());
260+
if (Object.keys(stats).length === 0) {
261+
const statKey = day.concat("_", "-");
262+
const statValue = [];
263+
statValue.push(day);
264+
if (this.#writePackageName) {
265+
statValue.push(this.#packageName);
266+
}
267+
statValue.push("-");
268+
statValue.push(0);
269+
stats[statKey] = statValue;
270+
}
260271
const grouped = this.#groupStats(
261272
lastWeek,
262273
stats,

0 commit comments

Comments
 (0)