diff options
Diffstat (limited to 'lib/getOptions.js')
| -rw-r--r-- | lib/getOptions.js | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/lib/getOptions.js b/lib/getOptions.js index eab67f4..350af68 100644 --- a/lib/getOptions.js +++ b/lib/getOptions.js @@ -9,10 +9,16 @@ var getBaseOptions = function(cb){ var git_commit = process.env.COVERALLS_GIT_COMMIT; var git_branch = process.env.COVERALLS_GIT_BRANCH; + var match = (process.env.CI_PULL_REQUEST || "").match(/(\d+)$/); + + if (match) { + options.service_pull_request = match[1]; + } + if (process.env.TRAVIS){ options.service_name = 'travis-ci'; options.service_job_id = process.env.TRAVIS_JOB_ID; - git_commit = process.env.TRAVIS_COMMIT; + git_commit = 'HEAD'; git_branch = process.env.TRAVIS_BRANCH; } @@ -28,6 +34,7 @@ var getBaseOptions = function(cb){ if (process.env.JENKINS_URL){ options.service_name = 'jenkins'; options.service_job_id = process.env.BUILD_ID; + options.service_pull_request = process.env.ghprbPullId; git_commit = process.env.GIT_COMMIT; git_branch = process.env.GIT_BRANCH; } @@ -62,7 +69,7 @@ var getBaseOptions = function(cb){ } if (!git_commit || !git_branch) { - var data = require('./detectLocalGit')(git_commit, git_branch); + var data = require('./detectLocalGit')(); if (data) { git_commit = git_commit || data.git_commit; git_branch = git_branch || data.git_branch; @@ -108,11 +115,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 +133,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); }); }; |
