[Pkg-javascript-commits] [node-coveralls] 194/332: allow users to pass options through.
Bastien Roucariès
rouca at moszumanska.debian.org
Thu Nov 9 13:53:59 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 6d2e7203351b34dd53eed0dee796d93e0e10d4e7
Author: Jacob Meacham <jacob.e.meacham at gmail.com>
Date: Thu Jan 29 00:06:09 2015 -0800
allow users to pass options through.
---
lib/getOptions.js | 11 +++++++++--
lib/handleInput.js | 7 ++++---
test/getOptions.js | 8 ++++++++
3 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/lib/getOptions.js b/lib/getOptions.js
index eab67f4..9713f03 100644
--- a/lib/getOptions.js
+++ b/lib/getOptions.js
@@ -108,11 +108,13 @@ var getBaseOptions = function(cb){
}
};
-var getOptions = function(cb){
+var getOptions = function(cb, _userOptions){
if (!cb){
throw new Error('getOptions requires a callback');
}
+ var userOptions = _userOptions || {};
+
getBaseOptions(function(err, options){
// try to get filepath from the command-line
if (process.argv[2]) {
@@ -124,7 +126,12 @@ var getOptions = function(cb){
options.filepath = process.argv[2];
}
}
- cb(err, options);
+
+ // lodash or else would be better, but no need for the extra dependency
+ for (var option in userOptions) {
+ options[option] = userOptions[option];
+ }
+ cb(err, options);
});
};
diff --git a/lib/handleInput.js b/lib/handleInput.js
index 5f88394..845bfad 100644
--- a/lib/handleInput.js
+++ b/lib/handleInput.js
@@ -1,9 +1,10 @@
var index = require('../index');
var logger = require('./logger')();
-function handleInput(input, cb) {
+function handleInput(input, cb, userOptions) {
logger.debug(input);
- var options = index.getOptions(function(err, options){
+ logger.debug('user options ' + userOptions);
+ index.getOptions(function(err, options){
if (err){
logger.error("error from getOptions");
@@ -33,7 +34,7 @@ function handleInput(input, cb) {
cb(null);
});
});
- });
+ }, userOptions);
}
module.exports = handleInput;
diff --git a/test/getOptions.js b/test/getOptions.js
index 8a77708..6f9ddc5 100644
--- a/test/getOptions.js
+++ b/test/getOptions.js
@@ -135,6 +135,14 @@ describe("getOptions", function(){
it ("should set service_name and service_job_id if it's running on wercker", function(done){
testWercker(getOptions, done);
});
+ it ("should override set options with user options", function(done){
+ var userOptions = {service_name: 'OVERRIDDEN_SERVICE_NAME'};
+ process.env.COVERALLS_SERVICE_NAME = "SERVICE_NAME";
+ getOptions(function(err, options){
+ options.service_name.should.equal("OVERRIDDEN_SERVICE_NAME");
+ done();
+ }, userOptions);
+ });
});
var testServiceJobId = function(sut, done){
--
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