[Pkg-javascript-commits] [node-coveralls] 98/332: Added getBaseOptions to allow setting up options without depending on process.argv

Bastien Roucariès rouca at moszumanska.debian.org
Thu Nov 9 13:53:45 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-coveralls.

commit 3ab2c57bdde97787c313623b4f7638e909c5aafd
Author: Matthew J. Morrison <mattjmorrison at mattjmorrison.com>
Date:   Fri Sep 6 18:32:30 2013 -0500

    Added getBaseOptions to allow setting up options without depending on process.argv
---
 lib/getOptions.js | 44 ++++++++++++++++++++++++--------------------
 1 file changed, 24 insertions(+), 20 deletions(-)

diff --git a/lib/getOptions.js b/lib/getOptions.js
index 4a4d959..8ce948c 100644
--- a/lib/getOptions.js
+++ b/lib/getOptions.js
@@ -4,24 +4,8 @@ var yaml = require('yaml');
 var logger = require('./logger')();
 var fetchGitData = require('./fetchGitData');
 
-var getOptions = function(cb){
-  if (!cb){
-    throw new Error('getOptions requires a callback');
-  }
-	var options = {};
-
-	// try to get filepath from the command-line
-	if (process.argv[2]) {
-		if (~['-v', '--verbose'].indexOf(process.argv[2])) {
-			if (process.argv[3]) {
-				options.filepath = process.argv[3];
-			}
-		} else {
-			options.filepath = process.argv[2];
-		}
-	}
-
-
+var getBaseOptions = function(cb){
+  var options = {};
   var git_commit = process.env.COVERALLS_GIT_COMMIT;
   var git_branch = process.env.COVERALLS_GIT_BRANCH;
 
@@ -59,11 +43,11 @@ var getOptions = function(cb){
     options.service_job_id = process.env.COVERALLS_SERVICE_JOB_ID;
   }
 
-	// try to get the repo token as an environment variable
+  // try to get the repo token as an environment variable
   if (process.env.COVERALLS_REPO_TOKEN) {
     options.repo_token = process.env.COVERALLS_REPO_TOKEN;
   } else {
-		// try to get the repo token from a .coveralls.yml file
+    // try to get the repo token from a .coveralls.yml file
     var yml = path.join(process.cwd(), '.coveralls.yml');
     try {
       if (fs.statSync(yml).isFile()) {
@@ -92,7 +76,27 @@ var getOptions = function(cb){
   } else {
     return cb(null, options);
   }
+};
+
+var getOptions = function(cb){
+  if (!cb){
+    throw new Error('getOptions requires a callback');
+  }
 
+  getBaseOptions(function(err, options){
+    // try to get filepath from the command-line
+    if (process.argv[2]) {
+      if (~['-v', '--verbose'].indexOf(process.argv[2])) {
+        if (process.argv[3]) {
+          options.filepath = process.argv[3];
+        }
+      } else {
+        options.filepath = process.argv[2];
+      }
+    }
+      cb(err, options);
+  });
 };
 
+module.exports = getBaseOptions;
 module.exports = getOptions;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-coveralls.git



More information about the Pkg-javascript-commits mailing list