blob: f314b003613b4b3dbd25815907aae999583812d9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
var fs = require('fs');
var path = require('path');
var YAML = require('libyaml');
var logger = require('./logger');
var getOptions = function(){
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];
}
}
// 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
var yml = path.join(process.cwd(), '.coveralls.yml');
try {
if (fs.statSync(yml).isFile()) {
options.repo_token = YAML.readFileSync(yml)[0].repo_token;
}
} catch(ex){
logger.warn("Repo token could not be determined. Continuing without it.");
}
}
return options;
};
module.exports = getOptions;
|