Socket
Socket
Sign inDemoInstall

codecov

Package Overview
Dependencies
Maintainers
3
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

codecov - npm Package Compare versions

Comparing version 1.0.1 to 2.0.0

codecov.yml

27

lib/codecov.js
var fs = require('fs');
var path = require('path');
var request = require('request');
var urlgrey = require('urlgrey');
var execSync = require('child_process').execSync;
if (!execSync) {
var exec = require('execSync').exec;
var execSync = function(cmd){
return exec(cmd).stdout;
};
}

@@ -77,3 +72,3 @@ var detectProvider = require('./detect');

var sendToCodecovV2 = function(codecov_endpoint, query, body, on_success, on_failure){
var sendToCodecovV2 = function(codecov_endpoint, query, upload_body, on_success, on_failure){
// Direct to Codecov

@@ -83,3 +78,3 @@ request.post(

url : urlgrey(codecov_endpoint + '/upload/v2').query(query).toString(),
body : body,
body : upload_body,
headers : {

@@ -89,6 +84,6 @@ 'Content-Type': 'text/plain',

}
}, function(err, response, body){
}, function(err, response, result){
if (err || response.statusCode !== 200) {
console.log(' ' + (err || response.body));
return on_failure(response.statusCode, response.body);
return response ? on_failure(response.statusCode, response.body) : on_failure(err.code, err.message);

@@ -107,3 +102,3 @@ } else {

var sendToCodecovV3 = function(codecov_endpoint, query, body, on_success, on_failure){
var sendToCodecovV3 = function(codecov_endpoint, query, upload_body, on_success, on_failure){
// Direct to S3

@@ -120,3 +115,3 @@ request.post(

if (err) {
sendToCodecovV2(codecov_endpoint, query, body, on_success, on_failure);
sendToCodecovV2(codecov_endpoint, query, upload_body, on_success, on_failure);

@@ -128,3 +123,3 @@ } else {

url : result.split('\n')[1],
body : body,
body : upload_body,
headers : {

@@ -136,3 +131,3 @@ 'Content-Type': 'plain/text',

if (err) {
sendToCodecovV2(codecov_endpoint, query, body, on_success, on_failure);
sendToCodecovV2(codecov_endpoint, query, upload_body, on_success, on_failure);

@@ -168,2 +163,6 @@ } else {

query.yaml = ['codecov.yml', '.codecov.yml'].reduce(function (result, file) {
return result || (fs.existsSync(path.resolve(process.cwd(), file)) ? file : undefined)
}, undefined)
if ((args.options.disable || '').split(',').indexOf('detect') === -1) {

@@ -170,0 +169,0 @@ console.log('==> Detecting CI Provider');

@@ -16,6 +16,21 @@ module.exports = {

pr: process.env.CIRCLE_PR_NUMBER,
slug : process.env.CIRCLE_PROJECT_USERNAME + '/' + process.env.CIRCLE_PROJECT_REPONAME,
slug : detectRepoSlug(),
};
function detectRepoSlug(){
if (process.env.CIRCLE_PROJECT_REPONAME) {
// CircleCI 1.0
// CIRCLE_PROJECT_REPONAME=codecov
// CIRCLE_PROJECT_USERNAME=codecov-node
// CIRCLE_REPOSITORY_URL=https://github.com/codecov/codecov-node (note: GitHub Web URL)
return process.env.CIRCLE_PROJECT_USERNAME + '/' + process.env.CIRCLE_PROJECT_REPONAME;
}
if (process.env.CIRCLE_REPOSITORY_URL) {
// CircleCI 2.0
// CIRCLE_REPOSITORY_URL=git@github.com:codecov/codecov-node.git (note: Git/SSH URL)
return process.env.CIRCLE_REPOSITORY_URL.replace(/^.*:/, '').replace(/\.git$/, '');
}
throw new Error('Cannot detect repository slug.');
}
}
};
var execSync = require('child_process').execSync;
if (!execSync) {
var exec = require('execSync').exec;
var execSync = function(cmd){
return exec(cmd).stdout;
};
}

@@ -9,0 +3,0 @@ module.exports = {

@@ -1,3 +0,2 @@

// http://doc.gitlab.com/ci/examples/README.html#environmental-variables
// https://gitlab.com/gitlab-org/gitlab-ci-runner/blob/master/lib/build.rb#L96
// https://docs.gitlab.com/ce/ci/variables/README.html

@@ -7,3 +6,3 @@ module.exports = {

detect : function(){
return process.env.CI_SERVER_NAME == 'GitLab CI';
return !!process.env.GITLAB_CI;
},

@@ -10,0 +9,0 @@

var execSync = require('child_process').execSync;
if (!execSync) {
var exec = require('execSync').exec;
var execSync = function(cmd){
return exec(cmd).stdout;
};
}

@@ -9,0 +3,0 @@ module.exports = {

{
"name": "codecov",
"version": "1.0.1",
"version": "2.0.0",
"description": "Uploading report to Codecov: https://codecov.io",

@@ -22,2 +22,5 @@ "main": "index.js",

},
"engines": {
"node": ">=0.12"
},
"author": "Codecov <hello@codecov.io>",

@@ -30,13 +33,12 @@ "license": "MIT",

"dependencies": {
"request": ">=2.42.0",
"urlgrey": ">=0.4.0",
"argv": ">=0.0.2",
"execSync": "1.0.2"
"request": "2.79.0",
"urlgrey": "0.4.4",
"argv": "0.0.2"
},
"devDependencies": {
"expect.js": "0.3.1",
"istanbul": "0.3.2",
"jshint": "2.5.5",
"mocha": "2.2.1"
"expect.js": "^0.3.1",
"istanbul": "^0.4.5",
"jshint": "^2.9.3",
"mocha": "^3.0.2"
}
}

@@ -13,3 +13,3 @@ # Codecov NodeJS Uploader

```
npm install codecov --save
npm install codecov --save-dev
```

@@ -59,22 +59,7 @@

----
## Advanced: Partial Line Coverage
**Codecov does support partial line coverage**. However, some node projects do not report partial coverage accurate enough.
You can decide to upload the partial coverage report by chaning the target upload file to `./coverage/coverage.json`.
View your report on Codecov, if the reports are not accurate then switch back to the `lcov` provided above.
We are working on improving this implementation and appreciate your patience.
## Contributing
I generally don't accept pull requests that are untested, or break the build, because I'd like to keep the quality high (this is a coverage tool afterall!).
I also don't care for "soft-versioning" or "optimistic versioning" (dependencies that have ^, x, > in them, or anything other than numbers and dots). There have been too many problems with bad semantic versioning in dependencies, and I'd rather have a solid library than a bleeding edge one.
[travis-image]: https://travis-ci.org/codecov/codecov-node.svg?branch=master
[travis-url]: https://travis-ci.org/codecov/codecov-node
[npm-url]: https://npmjs.org/package/codecov.io
[npm-image]: https://img.shields.io/npm/v/codecov.io.svg
[npm-url]: https://npmjs.org/package/codecov
[npm-image]: https://img.shields.io/npm/v/codecov.svg

@@ -86,1 +71,9 @@ [depstat-url]: https://david-dm.org/codecov/codecov-node

[devdepstat-image]: https://img.shields.io/david/dev/codecov/codecov-node/master.svg
**With NYC**
```
nyc npm test
nyc report --reporter=text-lcov > coverage.lcov
./node_modules/.bin/codecov
```

@@ -54,7 +54,7 @@ var fs = require('fs');

it("can detect .bowerrc with directory", function(){
fs.writeFileSync('.bowerrc', '{"directory": "test"}');
var res = codecov.upload({options: {dump: true}});
expect(res.files).to.eql([]);
});
// it("can detect .bowerrc with directory", function(){
// fs.writeFileSync('.bowerrc', '{"directory": "test"}');
// var res = codecov.upload({options: {dump: true}});
// expect(res.files).to.eql([]);
// });

@@ -61,0 +61,0 @@ it("can detect .bowerrc without directory", function(){

@@ -10,3 +10,3 @@ var circle = require("../../lib/services/circle");

it ("can get circle env info get_commit_status", function(){
it ("can get circle env info (CircleCI 1.0)", function(){
process.env.CIRCLECI = 'true';

@@ -31,2 +31,36 @@ process.env.CIRCLE_BUILD_NUM = '1234';

it ("can get circle env info (CircleCI 2.0)", function(){
process.env.CIRCLECI = 'true';
process.env.CIRCLE_BRANCH = 'master';
process.env.CIRCLE_BUILD_NUM = '1234';
process.env.CIRCLE_SHA1 = 'abcd';
process.env.CIRCLE_NODE_INDEX = '1';
process.env.CIRCLE_BUILD_URL = 'https://circleci.com/gh/owner/repo/1234';
process.env.CIRCLE_COMPARE_URL = 'https://github.com/owner/repo/2408ca9...3c36cfa';
process.env.CIRCLE_NODE_INDEX = '1';
process.env.CIRCLE_REPOSITORY_URL = 'git@github.com:owner/repo.git';
delete process.env.CIRCLE_PR_NUMBER;
delete process.env.CIRCLE_PROJECT_USERNAME;
delete process.env.CIRCLE_PROJECT_REPONAME;
expect(circle.configuration()).to.eql({
service : 'circleci',
commit : 'abcd',
build : '1234.1',
job : '1234.1',
branch : 'master',
pr : undefined,
slug : 'owner/repo'
});
});
it ("throws if repo slug cannot be detected", function(){
delete process.env.CIRCLE_PR_NUMBER;
delete process.env.CIRCLE_PROJECT_USERNAME;
delete process.env.CIRCLE_PROJECT_REPONAME;
delete process.env.CIRCLE_REPOSITORY_URL;
expect(function(){
circle.configuration();
}).to.throw(Error);
});
});

@@ -6,3 +6,3 @@ var gitlab = require("../../lib/services/gitlab");

it ("can detect gitlab", function(){
process.env.CI_SERVER_NAME = "GitLab CI";
process.env.GITLAB_CI = "true";
expect(gitlab.detect()).to.be(true);

@@ -9,0 +9,0 @@ });

@@ -26,6 +26,7 @@ var snap = require("../../lib/services/snap");

it ("can get snap env info get_commit_status for pull requests", function(){
process.env.SNAP_COMMIT = '';
process.env.SNAP_BRANCH = '';
process.env.SNAP_CI = "true";
process.env.SNAP_PIPELINE_COUNTER = '1234';
process.env.SNAP_COMMIT = '5678';
process.env.SNAP_UPSTREAM_COMMIT = '5678';
process.env.SNAP_UPSTREAM_BRANCH = 'upstream-branch';

@@ -32,0 +33,0 @@ process.env.SNAP_PULL_REQUEST_NUMBER = 'blah';

var fs = require('fs');
var codecov = require("../lib/codecov");
var codecov = require('../lib/codecov');
var offlineErrors = require('../lib/offline');
var execSync = require('child_process').execSync;

@@ -14,5 +15,6 @@ if (!execSync) {

it("can get upload to v2", function(done){
var self = this;
codecov.sendToCodecovV2('https://codecov.io',
{
token: '473c8c5b-10ee-4d83-86c6-bfd72a185a27',
token: 'f881216b-b5c0-4eb1-8f21-b51887d1d506',
commit: 'c739768fcac68144a3a6d82305b9c4106934d31a',

@@ -23,7 +25,11 @@ branch: 'master'

function(body){
expect(body).to.contain('http://codecov.io/github/codecov/ci-repo?ref=c739768fcac68144a3a6d82305b9c4106934d31a');
expect(body).to.contain('https://codecov.io/github/codecov/ci-repo/commit/c739768fcac68144a3a6d82305b9c4106934d31a');
done();
},
function(err){
throw err;
function(errCode, errMsg){
if(offlineErrors.indexOf(errCode) !== -1){
self.skip(); // offline - we can not test upload
return;
}
throw new Error(errMsg);
});

@@ -33,5 +39,7 @@ });

it("can get upload to v3", function(done){
var self = this;
this.timeout(3000); // give this test extra time to run (default is 2000ms)
codecov.sendToCodecovV3('https://codecov.io',
{
token: '473c8c5b-10ee-4d83-86c6-bfd72a185a27',
token: 'f881216b-b5c0-4eb1-8f21-b51887d1d506',
commit: 'c739768fcac68144a3a6d82305b9c4106934d31a',

@@ -42,10 +50,36 @@ branch: 'master'

function(body){
expect(body).to.contain('http://codecov.io/github/codecov/ci-repo?ref=c739768fcac68144a3a6d82305b9c4106934d31a');
expect(body).to.contain('https://codecov.io/github/codecov/ci-repo/commit/c739768fcac68144a3a6d82305b9c4106934d31a');
done();
},
function(err){
throw err;
function(errCode, errMsg){
if(offlineErrors.indexOf(errCode) !== -1){
self.skip(); // offline - we can not test upload
return;
}
throw new Error(errMsg);
});
});
it("upload v2 doesn't throw runtime error", function(done){
expect(codecov.sendToCodecovV2.bind(null,
'https://codecov.io',
{
token: 'f881216b-b5c0-4eb1-8f21-b51887d1d506',
commit: 'c739768fcac68144a3a6d82305b9c4106934d31a',
branch: 'master'
},
'testing node-'+codecov.version,
function(body){
expect(body).to.contain('https://codecov.io/github/codecov/ci-repo/commit/c739768fcac68144a3a6d82305b9c4106934d31a');
done();
},
function(errCode, errMsg){
if(offlineErrors.indexOf(errCode) !== -1){
done();
}
throw new Error(errMsg);
}
)).to.not.throwException();
})
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc