mirror of
https://github.com/IonicaBizau/git-stats.git
synced 2024-12-22 13:22:11 +01:00
⬆️ 2.7.0
Fixed the getConfig method error sending.
This commit is contained in:
parent
023972eb7b
commit
0208b8239d
2 changed files with 15 additions and 11 deletions
24
lib/index.js
24
lib/index.js
|
@ -74,23 +74,26 @@ GitStats.DEFAULT_CONFIG = {
|
||||||
* @return {Object|Undefined} If no callback is provided, the configuration object will be returned.
|
* @return {Object|Undefined} If no callback is provided, the configuration object will be returned.
|
||||||
*/
|
*/
|
||||||
GitStats.prototype.getConfig = function (callback) {
|
GitStats.prototype.getConfig = function (callback) {
|
||||||
var data = null;
|
var data = {}
|
||||||
|
, err = null
|
||||||
|
;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
data = require(CONFIG_PATH);
|
data = require(CONFIG_PATH);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err.code !== "MODULE_NOT_FOUND") {
|
if (err.code === "MODULE_NOT_FOUND") {
|
||||||
if (callback) {
|
err = null;
|
||||||
return callback(err);
|
data = {};
|
||||||
} else {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (callback) {
|
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) {
|
GitStats.prototype.initConfig = function (input, callback) {
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
if (Typpy(input, Function)) {
|
if (Typpy(input, Function)) {
|
||||||
callback = input;
|
callback = input;
|
||||||
input = null;
|
input = null;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "git-stats",
|
"name": "git-stats",
|
||||||
"version": "2.6.0",
|
"version": "2.7.0",
|
||||||
"description": "Local git statistics including GitHub-like contributions calendars.",
|
"description": "Local git statistics including GitHub-like contributions calendars.",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
|
Loading…
Reference in a new issue