aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXhmikosR <[email protected]>2020-04-23 21:08:35 +0300
committerGitHub <[email protected]>2020-04-23 11:08:35 -0700
commit3647673f9e43ea973ebed65a891e897415cb2389 (patch)
tree23d34a1565e8dc75b1f5623c4ea6846eb2b6738c
parentff21930515e15e367a3d033230d0c5def75fc206 (diff)
downloadnode-coveralls-3647673f9e43ea973ebed65a891e897415cb2389.tar.xz
node-coveralls-3647673f9e43ea973ebed65a891e897415cb2389.zip
Minor lint tweaks (#285)
-rw-r--r--lib/convertLcovToCoveralls.js19
-rw-r--r--lib/getOptions.js3
-rw-r--r--test/convertLcovToCoveralls.js2
-rw-r--r--test/getOptions.js50
4 files changed, 45 insertions, 29 deletions
diff --git a/lib/convertLcovToCoveralls.js b/lib/convertLcovToCoveralls.js
index 710c87d..416b3b4 100644
--- a/lib/convertLcovToCoveralls.js
+++ b/lib/convertLcovToCoveralls.js
@@ -7,19 +7,23 @@ const logger = require('./logger')();
const detailsToCoverage = (length, details) => {
const coverage = new Array(length);
+
details.forEach(obj => {
coverage[obj.line - 1] = obj.hit;
});
+
return coverage;
};
const detailsToBranches = details => {
const branches = [];
+
details.forEach(obj => {
['line', 'block', 'branch', 'taken'].forEach(key => {
branches.push(obj[key] || 0);
});
});
+
return branches;
};
@@ -67,7 +71,7 @@ const convertLcovToCoveralls = (input, options, cb) => {
if (options.flag_name) {
postJson.flag_name = options.flag_name;
}
-
+
if (options.git) {
postJson.git = options.git;
}
@@ -79,11 +83,11 @@ const convertLcovToCoveralls = (input, options, cb) => {
if (options.service_name) {
postJson.service_name = options.service_name;
}
-
+
if (options.service_number) {
postJson.service_number = options.service_number;
}
-
+
if (options.service_job_id) {
postJson.service_job_id = options.service_job_id;
}
@@ -107,6 +111,7 @@ const convertLcovToCoveralls = (input, options, cb) => {
postJson.source_files.push(convertLcovFileObject(file, filepath));
}
});
+
return cb(null, postJson);
});
};
@@ -134,7 +139,7 @@ module.exports = convertLcovToCoveralls;
example output from lcov parser:
- [
+[
{
"file": "index.js",
"lines": {
@@ -156,6 +161,10 @@ example output from lcov parser:
{
"line": 5,
"hit": 1
- },
+ }
+ ]
+ }
+ }
+]
*/
diff --git a/lib/getOptions.js b/lib/getOptions.js
index 7fcbf08..2f9c9fb 100644
--- a/lib/getOptions.js
+++ b/lib/getOptions.js
@@ -180,6 +180,7 @@ const getBaseOptions = cb => {
if (coveralls_yaml_conf.repo_token) {
options.repo_token = coveralls_yaml_conf.repo_token;
}
+
if (coveralls_yaml_conf.service_name) {
options.service_name = coveralls_yaml_conf.service_name;
}
@@ -190,7 +191,7 @@ const getBaseOptions = cb => {
options.repo_token = process.env.COVERALLS_REPO_TOKEN;
}
- if ('travis-pro' === options.service_name && !options.repo_token) {
+ if (options.service_name === 'travis-pro' && !options.repo_token) {
logger.warn('Repo token could not be determined. Continuing without it. ' +
'This is necessary for private repos only, so may not be an issue at all.');
}
diff --git a/test/convertLcovToCoveralls.js b/test/convertLcovToCoveralls.js
index 4ce10d2..92ee40d 100644
--- a/test/convertLcovToCoveralls.js
+++ b/test/convertLcovToCoveralls.js
@@ -93,7 +93,7 @@ describe('convertLcovToCoveralls', () => {
fs.existsSync = originalExistsSync;
should.not.exist(err);
- output.source_files[0].name.should.equal(path.posix.join("svgo", "config.js"));
+ output.source_files[0].name.should.equal(path.posix.join('svgo', 'config.js'));
done();
});
});
diff --git a/test/getOptions.js b/test/getOptions.js
index 4ff32d5..8ed95c6 100644
--- a/test/getOptions.js
+++ b/test/getOptions.js
@@ -134,10 +134,10 @@ describe('getOptions', () => {
it('should set service_name if it exists', done => {
testServiceName(getOptions, done);
});
- it ("should set service_number if it exists", done => {
+ it('should set service_number if it exists', done => {
testServiceNumber(getOptions, done);
});
- it("should set service_pull_request if it exists", done => {
+ it('should set service_pull_request if it exists', done => {
testServicePullRequest(getOptions, done);
});
it('should set service_name and service_job_id if it\'s running on travis-ci', done => {
@@ -164,7 +164,7 @@ describe('getOptions', () => {
it('should set service_name and service_job_id if it\'s running on Gitlab', done => {
testGitlab(getOptions, done);
});
- it ("should set service_name and service_job_id if it's running on AppVeyor", done => {
+ it('should set service_name and service_job_id if it\'s running on AppVeyor', done => {
testAppVeyor(getOptions, done);
});
it('should set service_name and service_job_id if it\'s running via Surf', done => {
@@ -565,26 +565,32 @@ const testGitlab = (sut, done) => {
});
};
-const testAppVeyor = function(sut, done) {
+const testAppVeyor = (sut, done) => {
process.env.APPVEYOR = true;
- process.env.APPVEYOR_BUILD_ID = "1234";
- process.env.APPVEYOR_BUILD_NUMBER = "5678";
- process.env.APPVEYOR_REPO_COMMIT = "e3e3e3e3e3e3e3e3e";
- process.env.APPVEYOR_REPO_BRANCH = "feature";
-
- sut(function(err, options){
- options.service_name.should.equal("appveyor");
- options.service_job_id.should.equal("1234");
- options.service_job_number.should.equal("5678");
- options.git.should.eql({ head:
- { id: 'e3e3e3e3e3e3e3e3e',
- author_name: 'Unknown Author',
- author_email: '',
- committer_name: 'Unknown Committer',
- committer_email: '',
- message: 'Unknown Commit Message' },
- branch: 'feature',
- remotes: [] });
+ process.env.APPVEYOR_BUILD_ID = '1234';
+ process.env.APPVEYOR_BUILD_NUMBER = '5678';
+ process.env.APPVEYOR_REPO_COMMIT = 'e3e3e3e3e3e3e3e3e';
+ process.env.APPVEYOR_REPO_BRANCH = 'feature';
+
+ const git = {
+ head: {
+ id: 'e3e3e3e3e3e3e3e3e',
+ author_name: 'Unknown Author',
+ author_email: '',
+ committer_name: 'Unknown Committer',
+ committer_email: '',
+ message: 'Unknown Commit Message'
+ },
+ branch: 'feature',
+ remotes: []
+ };
+
+ sut((err, options) => {
+ should.not.exist(err);
+ options.service_name.should.equal('appveyor');
+ options.service_job_id.should.equal('1234');
+ options.service_job_number.should.equal('5678');
+ options.git.should.eql(git);
done();
});
};