mirror of
https://github.com/IonicaBizau/git-stats.git
synced 2024-09-29 19:51:29 +02:00
Fixed #2. Check if the file is not found. If so, create it.
This commit is contained in:
parent
c70ecec82e
commit
093ce0d9ce
@ -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 New Issue
Block a user