diff options
| author | Nick Merwin <[email protected]> | 2015-12-10 17:05:25 -0800 |
|---|---|---|
| committer | Nick Merwin <[email protected]> | 2015-12-10 17:05:25 -0800 |
| commit | 8c06415c4dfbd72043f26afdf7e34313d5c4444d (patch) | |
| tree | 9c70af72c5ce61d6df81ddccd7d01f9a6e2d31ad /lib | |
| parent | 83c3dfdff827a82de0b410c297e66d3d194210c1 (diff) | |
| parent | ddc813c0945a5530c1f4b226484961c13cb01f21 (diff) | |
| download | node-coveralls-8c06415c4dfbd72043f26afdf7e34313d5c4444d.tar.xz node-coveralls-8c06415c4dfbd72043f26afdf7e34313d5c4444d.zip | |
Merge branch 'master' of github.com:nickmerwin/node-coveralls
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/getOptions.js | 16 | ||||
| -rw-r--r-- | lib/logger.js | 8 | ||||
| -rw-r--r-- | lib/sendToCoveralls.js | 13 |
3 files changed, 19 insertions, 18 deletions
diff --git a/lib/getOptions.js b/lib/getOptions.js index 144d0ad..4c53e36 100644 --- a/lib/getOptions.js +++ b/lib/getOptions.js @@ -1,6 +1,7 @@ var fs = require('fs'); var path = require('path'); var yaml = require('js-yaml'); +var index = require('../index'); var logger = require('./logger')(); var fetchGitData = require('./fetchGitData'); @@ -128,16 +129,11 @@ var getOptions = function(cb, _userOptions){ var userOptions = _userOptions || {}; 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]; - } - } + // minimist populates options._ with non-option command line arguments + var firstNonOptionArgument = index.options._[0]; + + if (firstNonOptionArgument) + options.filepath = firstNonOptionArgument; // lodash or else would be better, but no need for the extra dependency for (var option in userOptions) { diff --git a/lib/logger.js b/lib/logger.js index 9c27e0b..f834586 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -1,18 +1,16 @@ +var index = require('../index'); + module.exports = function(){ return require('log-driver')({level : getLogLevel()}); }; function getLogLevel(){ - if (hasVerboseCommandLineOption() || hasDebugEnvVariable()) { + if (index.options.verbose || hasDebugEnvVariable()) { return 'warn'; } return 'error'; } -function hasVerboseCommandLineOption(){ - return process.argv[2] && ~['-v', '--verbose'].indexOf(process.argv[2]); -} - function hasDebugEnvVariable(){ return process.env.NODE_COVERALLS_DEBUG == 1; } diff --git a/lib/sendToCoveralls.js b/lib/sendToCoveralls.js index 38b37f7..fcf63a8 100644 --- a/lib/sendToCoveralls.js +++ b/lib/sendToCoveralls.js @@ -1,4 +1,5 @@ var request = require('request'); +var index = require('../index'); var sendToCoveralls = function(obj, cb){ var urlBase = 'https://coveralls.io'; @@ -8,9 +9,15 @@ var sendToCoveralls = function(obj, cb){ var str = JSON.stringify(obj); var url = urlBase + '/api/v1/jobs'; - request.post({url : url, form : { json : str}}, function(err, response, body){ - cb(err, response, body); - }); + + if (index.options.stdout) { + process.stdout.write(str); + cb(null, { statusCode: 200 }, ''); + } else { + request.post({url : url, form : { json : str}}, function(err, response, body){ + cb(err, response, body); + }); + } }; module.exports = sendToCoveralls; |
