From 66d51ae7b0581091f15c42365f06a8b7dc587364 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionic=C4=83=20Biz=C4=83u?= Date: Mon, 14 Sep 2015 17:29:40 +0300 Subject: [PATCH] JSDoc comments --- bin/git-stats | 10 +++------- lib/index.js | 18 ++++++++++++++++++ package.json | 2 +- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/bin/git-stats b/bin/git-stats index 93f97d8..503ce1e 100755 --- a/bin/git-stats +++ b/bin/git-stats @@ -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) { diff --git a/lib/index.js b/lib/index.js index 8777251..5baf206 100644 --- a/lib/index.js +++ b/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; diff --git a/package.json b/package.json index 4501f26..49a8f35 100644 --- a/package.json +++ b/package.json @@ -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" },