mirror of
https://github.com/IonicaBizau/git-stats.git
synced 2025-01-03 10:22:11 +01:00
Added the record and get function.
This commit is contained in:
parent
e14f250a0e
commit
a84cc75120
1 changed files with 17 additions and 2 deletions
19
lib/index.js
19
lib/index.js
|
@ -3,9 +3,24 @@ var FsExtra = require("fs-extra")
|
|||
, Ul = require("ul")
|
||||
;
|
||||
|
||||
const STORE_PATH = Ul.USER_DIR + "/.git-stats";
|
||||
|
||||
// Constructor
|
||||
var GitStats = module.exports = {};
|
||||
|
||||
GitStats.record = function (data) {
|
||||
console.log(data);
|
||||
GitStats.record = function (data, callback) {
|
||||
FsExtra.readJSON(STORE_PATH, function (err, stats) {
|
||||
stats = stats || {};
|
||||
var thisRepo = stats[data.url] = Object(stats[data.url]);
|
||||
thisRepo[data.hash] = { date: data.date };
|
||||
FsExtra.writeJSON(STORE_PATH, stats, callback);
|
||||
});
|
||||
};
|
||||
|
||||
GitStats.get = function (data, callback) {
|
||||
if (typeof data === "function") {
|
||||
callback = data;
|
||||
data = {};
|
||||
}
|
||||
FsExtra.readJSON(STORE_PATH, callback);
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue