From 0208b8239d43e50b4866507fbd9fe3a1473fce25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionic=C4=83=20Biz=C4=83u?= Date: Thu, 19 Nov 2015 13:54:41 +0200 Subject: [PATCH] :arrow_up: 2.7.0 Fixed the getConfig method error sending. --- lib/index.js | 24 ++++++++++++++---------- package.json | 2 +- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/lib/index.js b/lib/index.js index b88ae01..46437fa 100644 --- a/lib/index.js +++ b/lib/index.js @@ -74,23 +74,26 @@ GitStats.DEFAULT_CONFIG = { * @return {Object|Undefined} If no callback is provided, the configuration object will be returned. */ GitStats.prototype.getConfig = function (callback) { - var data = null; + var data = {} + , err = null + ; + try { data = require(CONFIG_PATH); } catch (err) { - if (err.code !== "MODULE_NOT_FOUND") { - if (callback) { - return callback(err); - } else { - throw err; - } + if (err.code === "MODULE_NOT_FOUND") { + err = null; + data = {}; } - return {}; } + if (callback) { - callback(null, data); + return callback(err, data); + } else { + if (err) { + throw err; + } } - return data; }; /** @@ -105,6 +108,7 @@ GitStats.prototype.getConfig = function (callback) { GitStats.prototype.initConfig = function (input, callback) { var self = this; + if (Typpy(input, Function)) { callback = input; input = null; diff --git a/package.json b/package.json index 9dc233d..2cd1d40 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "git-stats", - "version": "2.6.0", + "version": "2.7.0", "description": "Local git statistics including GitHub-like contributions calendars.", "main": "lib/index.js", "bin": {