diff --git a/lib/index.js b/lib/index.js index b88ae01..ec03745 100644 --- a/lib/index.js +++ b/lib/index.js @@ -74,22 +74,27 @@ 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 +110,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": {