mirror of
https://github.com/IonicaBizau/git-stats.git
synced 2025-01-03 10:22:11 +01:00
Fixed #2. Check if the file is not found. If so, create it.
This commit is contained in:
parent
c70ecec82e
commit
093ce0d9ce
1 changed files with 7 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue