mirror of
https://github.com/IonicaBizau/git-stats.git
synced 2024-12-22 21:32:10 +01:00
Merge branch 'enoent-fix'
This commit is contained in:
commit
604db780ef
1 changed files with 9 additions and 2 deletions
11
lib/index.js
11
lib/index.js
|
@ -95,6 +95,13 @@ GitStats.record = function (data, callback) {
|
|||
*/
|
||||
GitStats.get = function (callback) {
|
||||
Fs.readFile(STORE_PATH, "utf-8", function (err, data) {
|
||||
|
||||
if (err && err.code === "ENOENT") {
|
||||
return GitStats.save({}, function (err) {
|
||||
callback(err, {});
|
||||
});
|
||||
}
|
||||
|
||||
if (err) { return callback(err); }
|
||||
try {
|
||||
data = JSON.parse(data);
|
||||
|
@ -246,13 +253,13 @@ GitStats.calendar = function (data, callback) {
|
|||
}
|
||||
});
|
||||
|
||||
levels = Math.ceil(cal.max / (LEVELS.length * 3));
|
||||
levels = cal.max / (LEVELS.length * 2);
|
||||
days.forEach(function (c) {
|
||||
cDay = graph[c];
|
||||
cal.days[c] = {
|
||||
c: cDay.c
|
||||
, level: !levels
|
||||
? 0 : (cLevel = Math.floor(cDay.c / levels )) >= 5
|
||||
? 0 : (cLevel = Math.round(cDay.c / levels)) >= 4
|
||||
? 4 : !cLevel && cDay.c > 0 ? 1 : cLevel
|
||||
};
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue