From c562c7ee3a34fa5ef3d4b5f3878d6a61d9da0d08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionic=C4=83=20Biz=C4=83u?= Date: Mon, 26 Jan 2015 09:58:03 +0200 Subject: [PATCH] Get stats using the get method. --- lib/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index 3aa6d16..665e8bf 100644 --- a/lib/index.js +++ b/lib/index.js @@ -25,9 +25,10 @@ var GitStats = module.exports = {}; * @return {undefined} */ GitStats.record = function (data, callback) { + + // Validate data callback = callback || function (err) { if (err) throw err; }; data = Object(data); - if (typeof data.date === "string") { data.date = Moment(data.date, "DDD MMM dd HH:mm:ss YYYY"); } @@ -44,7 +45,8 @@ GitStats.record = function (data, callback) { return callback(new Error("Invalid url field.")); } - FsExtra.readJSON(STORE_PATH, function (err, stats) { + // Get stats + GitStats.get(function (err, stats) { stats = stats || {}; var day = data.date.format("MMM DDD dd, YYYY") , today = stats[day] = Object(stats[day])