Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

danger-plugin-codecov

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

danger-plugin-codecov - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

32

dist/index.js

@@ -13,6 +13,9 @@ "use strict";

const fetch = require("node-fetch");
function codecov(options = {}) {
let debug = false;
function codecov(options = { debug: false }) {
return __awaiter(this, void 0, void 0, function* () {
debug = options.debug;
const lastCommit = danger.git.commits.pop() || false;
if (lastCommit === false) {
log("Skipping because last release is not set.");
// We do not have a commit in this pr

@@ -22,3 +25,5 @@ return;

const lastCommitSha = lastCommit.sha;
log(`lastCommitSha: ${lastCommitSha}`);
const repoName = danger.github.pr.base.repo.full_name;
log(`repoName: ${repoName}`);
const baseCoverage = yield retry(codecovBranch(repoName));

@@ -39,3 +44,5 @@ const lastCommitCoverage = yield retry(codecovCommit(repoName, lastCommitSha));

const diff = lastCommitCoverage - baseCoverage;
log(`diff: ${diff}`);
const change = diff >= 0 ? Change.increase : Change.decrease;
log(`change: ${change}`);
const absDiffFixed = Math.abs(diff).toFixed(1);

@@ -51,5 +58,12 @@ const sign = change === Change.increase ? "+" : "%E2%80%93";

exports.default = codecov;
function log(...args) {
if (debug) {
// tslint:disable-next-line:no-console
console.log(...args);
}
}
function timeout(delay) {
return __awaiter(this, void 0, void 0, function* () {
return new Promise((resolve) => {
log(`Waiting for ... ${delay}`);
setTimeout(resolve, delay);

@@ -61,12 +75,15 @@ });

return __awaiter(this, void 0, void 0, function* () {
let result;
let result = 0;
for (let i = 0; i < times; i++) {
try {
result = retrieveCoverage(yield call);
if (!isNaN(result)) {
if (!isNaN(parseFloat(result))) {
log(`Parsed coverage: ${result}`);
break;
}
log(`Failed to parse coverage, retrying`);
yield timeout(10000);
}
catch (e) {
// tslint:disable-next-line:no-console
console.error(e);

@@ -79,2 +96,3 @@ }

function retrieveCoverage(report) {
log("Received report:", JSON.stringify(report));
try {

@@ -97,3 +115,5 @@ return parseFloat(report.commit.totals.c);

return __awaiter(this, void 0, void 0, function* () {
return fetch(`${codecovApiBaseUrl}/${repoName}/commit/${sha}`).then((res) => res.json());
const url = `${codecovApiBaseUrl}/${repoName}/commit/${sha}`;
log(`Fetching from: ${url}`);
return fetch(url).then((res) => res.json());
});

@@ -103,3 +123,5 @@ }

return __awaiter(this, void 0, void 0, function* () {
return fetch(`${codecovApiBaseUrl}/${repoName}/branch/${branch}`).then((res) => res.json());
const url = `${codecovApiBaseUrl}/${repoName}/branch/${branch}`;
log(`Fetching from: ${url}`);
return fetch(url).then((res) => res.json());
});

@@ -106,0 +128,0 @@ }

2

package.json

@@ -20,3 +20,3 @@ {

],
"version": "1.0.4",
"version": "1.0.5",
"main": "dist/index.js",

@@ -23,0 +23,0 @@ "types": "dist/index.d.ts",

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