Skip to content

Commit

Permalink
Merge 3ab2c57 into 167119f
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjmorrison committed Sep 6, 2013
2 parents 167119f + 3ab2c57 commit ef85a15
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions lib/getOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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;

0 comments on commit ef85a15

Please sign in to comment.