mirror of
https://github.com/IonicaBizau/git-stats.git
synced 2024-12-22 05:12:11 +01:00
New dependencies: r-json, w-json, abs
Use r-json to read json files, w-json to write json files and abs to find the absolute path to the file.
This commit is contained in:
parent
0750c1e51a
commit
e419d6ff87
2 changed files with 13 additions and 14 deletions
16
lib/index.js
16
lib/index.js
|
@ -1,8 +1,9 @@
|
|||
// Dependencies
|
||||
var Ul = require("ul")
|
||||
, Fs = require("fs")
|
||||
, Abs = require("abs")
|
||||
, ReadJson = require("r-json")
|
||||
, WriteJson = require("w-json")
|
||||
, Moment = require("moment")
|
||||
, CliBox = require("cli-box")
|
||||
, Couleurs = require("couleurs")()
|
||||
, Gry = require("gry")
|
||||
, IsThere = require("is-there")
|
||||
|
@ -11,7 +12,7 @@ var Ul = require("ul")
|
|||
;
|
||||
|
||||
// Constants
|
||||
const STORE_PATH = Ul.USER_DIR + "/.git-stats"
|
||||
const STORE_PATH = Abs("~/.git-stats")
|
||||
, DATE_FORMAT = "MMM D, YYYY"
|
||||
;
|
||||
|
||||
|
@ -83,7 +84,7 @@ GitStats.record = function (data, callback) {
|
|||
* @return {GitStats} The `GitStats` object.
|
||||
*/
|
||||
GitStats.get = function (callback) {
|
||||
Fs.readFile(STORE_PATH, "utf-8", function (err, data) {
|
||||
ReadJson(STORE_PATH, "utf-8", function (err, data) {
|
||||
|
||||
if (err && err.code === "ENOENT") {
|
||||
return GitStats.save({}, function (err) {
|
||||
|
@ -92,11 +93,6 @@ GitStats.get = function (callback) {
|
|||
}
|
||||
|
||||
if (err) { return callback(err); }
|
||||
try {
|
||||
data = JSON.parse(data);
|
||||
} catch (e) {
|
||||
return callback(e);
|
||||
}
|
||||
callback(null, data);
|
||||
});
|
||||
return GitStats;
|
||||
|
@ -113,7 +109,7 @@ GitStats.get = function (callback) {
|
|||
* @return {GitStats} The `GitStats` object.
|
||||
*/
|
||||
GitStats.save = function (stats, callback) {
|
||||
Fs.writeFile(STORE_PATH, JSON.stringify(stats, null, 1), callback);
|
||||
WriteJson(STORE_PATH, stats, callback);
|
||||
return GitStats;
|
||||
};
|
||||
|
||||
|
|
11
package.json
11
package.json
|
@ -31,12 +31,15 @@
|
|||
},
|
||||
"homepage": "https://github.com/IonicaBizau/git-stats",
|
||||
"dependencies": {
|
||||
"ansi-parser": "^1.4.0",
|
||||
"bug-killer": "^1.0.0",
|
||||
"cli-box": "^2.1.1",
|
||||
"bug-killer": "^4.0.0",
|
||||
"clp": "^3.0.0",
|
||||
"git-stats-colors": "^1.2.0",
|
||||
"moment": "^2.9.0",
|
||||
"ul": "^2.1.0"
|
||||
"ul": "^5.0.0",
|
||||
"r-json": "^1.0.0",
|
||||
"w-json": "^1.0.0",
|
||||
"is-there": "^4.0.0",
|
||||
"cli-pie": "^2.0.0",
|
||||
"cli-gh-cal": "^1.0.0"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue