mirror of
https://github.com/IonicaBizau/git-stats.git
synced 2024-11-17 17:35:22 +01:00
Removed the fs-extra dependency.
This commit is contained in:
parent
e61edcd509
commit
94717d98a2
1 changed files with 17 additions and 5 deletions
22
lib/index.js
22
lib/index.js
|
@ -1,6 +1,6 @@
|
||||||
// Dependencies
|
// Dependencies
|
||||||
var FsExtra = require("fs-extra")
|
var Ul = require("ul")
|
||||||
, Ul = require("ul")
|
, Fs = require("fs")
|
||||||
, Moment = require("moment")
|
, Moment = require("moment")
|
||||||
, CliBox = require("cli-box")
|
, CliBox = require("cli-box")
|
||||||
;
|
;
|
||||||
|
@ -63,7 +63,7 @@ GitStats.record = function (data, callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof data.url !== "string" || !data.url) {
|
if (typeof data.url !== "string" || !data.url) {
|
||||||
return callback(new Error("Invalid url field."));
|
return callback(new Error("Invalid url field. This commit is not recorded into the git-stats history since you didn't added the remote url. You can import the previous commits using the git-stats-importer tool."));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get stats
|
// Get stats
|
||||||
|
@ -76,7 +76,7 @@ GitStats.record = function (data, callback) {
|
||||||
|
|
||||||
repo[data.hash] = { date: data.date };
|
repo[data.hash] = { date: data.date };
|
||||||
|
|
||||||
FsExtra.writeJSON(STORE_PATH, stats, callback);
|
GitStats.save(stats, callback);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -90,9 +90,21 @@ GitStats.record = function (data, callback) {
|
||||||
* @return {undefined}
|
* @return {undefined}
|
||||||
*/
|
*/
|
||||||
GitStats.get = function (callback) {
|
GitStats.get = function (callback) {
|
||||||
FsExtra.readJSON(STORE_PATH, callback);
|
Fs.readFile(STORE_PATH, "utf-8", function (err, data) {
|
||||||
|
if (err) { return callback(err); }
|
||||||
|
try {
|
||||||
|
data = JSON.parse(data);
|
||||||
|
} catch (e) {
|
||||||
|
return callback(e);
|
||||||
|
}
|
||||||
|
callback(null, data);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GitStats.save = function (stats, callback) {
|
||||||
|
Fs.writeFile(STORE_PATH, JSON.stringify(stats, null, 1), callback);
|
||||||
|
}
|
||||||
|
|
||||||
GitStats.iterateDays = function (data, callback) {
|
GitStats.iterateDays = function (data, callback) {
|
||||||
|
|
||||||
if (typeof data === "function") {
|
if (typeof data === "function") {
|
||||||
|
|
Loading…
Reference in a new issue