diff options
| author | Matthew J. Morrison <[email protected]> | 2013-09-06 18:32:30 -0500 |
|---|---|---|
| committer | Matthew J. Morrison <[email protected]> | 2013-09-06 18:32:30 -0500 |
| commit | 3ab2c57bdde97787c313623b4f7638e909c5aafd (patch) | |
| tree | f9135453b48f3ab5396b83214573bb3edc70f3ac /lib/getOptions.js | |
| parent | 167119f81ba7e244ccae1ee979be902dd6c24c0a (diff) | |
| download | node-coveralls-3ab2c57bdde97787c313623b4f7638e909c5aafd.tar.xz node-coveralls-3ab2c57bdde97787c313623b4f7638e909c5aafd.zip | |
Added getBaseOptions to allow setting up options without depending on process.argv
Diffstat (limited to 'lib/getOptions.js')
| -rw-r--r-- | lib/getOptions.js | 44 |
1 files 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; |
