mirror of
https://github.com/IonicaBizau/git-stats.git
synced 2024-12-22 13:22:11 +01:00
JSDoc comments
This commit is contained in:
parent
f28e390309
commit
66d51ae7b0
3 changed files with 22 additions and 8 deletions
|
@ -20,17 +20,15 @@ const CONFIG_PATH = GitStatsLib.CONFIG_PATH
|
|||
|
||||
// Configurations
|
||||
Moment.suppressDeprecationWarnings = true;
|
||||
GitStats.config = {};
|
||||
|
||||
try {
|
||||
GitStats.config = ReadJson(CONFIG_PATH);
|
||||
GitStats.initConfig();
|
||||
} catch (err) {
|
||||
if (err.code !== "ENOENT") {
|
||||
Logger.log("Failed to read the config file: " + err.stack, "warn");
|
||||
Logger.log("Failed to read the config file:\n" + err.stack, "warn");
|
||||
}
|
||||
}
|
||||
|
||||
GitStats.config = Ul.deepMerge(GitStats.config, DEFAULT_CONFIG);
|
||||
|
||||
// Parse the command line arguments
|
||||
var recordOpt = new Clp.Option(["record"], "Records a new commit. Don't use this unless you are a mad scientist. If you are a developer, just use this option as part of the module.", "data")
|
||||
, sinceDateOpt = new Clp.Option(["s", "since"], "Optional start date.", "date", GitStats.config.since)
|
||||
|
@ -85,10 +83,8 @@ if (GitStats.config.global_activity) {
|
|||
globalActivityOpt.is_provided = true;
|
||||
}
|
||||
|
||||
|
||||
// --record
|
||||
if (recordOpt.is_provided) {
|
||||
|
||||
try {
|
||||
options = JSON.parse(recordOpt.value.replace(/^\"|\"$/g, ""));
|
||||
} catch (e) {
|
||||
|
|
18
lib/index.js
18
lib/index.js
|
@ -67,6 +67,15 @@ GitStats.DEFAULT_CONFIG = {
|
|||
, global_activity: false
|
||||
};
|
||||
|
||||
/**
|
||||
* getConfig
|
||||
* Fetches the configuration object from file (`~/.git-stats-config.json`).
|
||||
*
|
||||
* @name getConfig
|
||||
* @function
|
||||
* @param {Function} callback The callback function.
|
||||
* @return {Object|Undefined} If no callback is provided, the configuration object will be returned.
|
||||
*/
|
||||
GitStats.prototype.getConfig = function (callback) {
|
||||
if (callback) {
|
||||
ReadJson(CONFIG_PATH, function (err, data) {
|
||||
|
@ -84,6 +93,15 @@ GitStats.prototype.getConfig = function (callback) {
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* initConfig
|
||||
* Inits the configuration field (`this.config`).
|
||||
*
|
||||
* @name initConfig
|
||||
* @function
|
||||
* @param {Object|String} input The path to a custom git-stats configuration file or the configuration object.
|
||||
* @param {Function} callback The callback function.
|
||||
*/
|
||||
GitStats.prototype.initConfig = function (input, callback) {
|
||||
|
||||
var self = this;
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
"moment": "^2.9.0",
|
||||
"progress": "1.1.8",
|
||||
"r-json": "^1.0.0",
|
||||
"typpy": "2.0.0",
|
||||
"typpy": "^2.1.0",
|
||||
"ul": "^5.0.0",
|
||||
"w-json": "^1.0.0"
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue