fetch-coverage
Advanced tools
Comparing version 1.1.0 to 2.0.0
23
index.js
'use strict'; | ||
const hostedGitInfo = require('hosted-git-info'); | ||
const find = require('lodash.find'); | ||
const fetchers = require('require-directory')(module, './lib', { recurse: false }); | ||
@@ -9,3 +8,3 @@ const shieldsIo = require('./lib/util/shieldsIo'); | ||
function tryBadges(options) { | ||
const coverageBadge = find(options.badges, (badge) => badge.info.type === 'coverage'); | ||
const coverageBadge = options.badges && options.badges.find((badge) => badge.info.type === 'coverage'); | ||
const shieldsIoUrl = coverageBadge && coverageBadge.urls.content; | ||
@@ -19,10 +18,10 @@ | ||
const promises = options.services.map((service) => { | ||
return fetchers[service] && fetchers[service](gitInfo, options) | ||
.catch((err) => { errors.push(err); }); | ||
}); | ||
const promises = options.services.map((service) => | ||
fetchers[service] && fetchers[service](gitInfo, options) | ||
.catch((err) => { errors.push(err); }) | ||
); | ||
return Promise.all(promises) | ||
.then((coverages) => { | ||
const coverage = find(coverages, (coverage) => coverage != null); | ||
const coverage = coverages.find((coverage) => coverage != null); | ||
@@ -51,10 +50,11 @@ if (coverage != null) { | ||
} catch (err) { | ||
return Promise.resolve(null); | ||
/* istanbul ignore next */ | ||
return null; | ||
} | ||
if (!gitInfo) { | ||
return Promise.resolve(null); | ||
return null; | ||
} | ||
options = Object.assign({ | ||
options = { | ||
branch: null, | ||
@@ -64,3 +64,4 @@ badges: null, | ||
got: { timeout: 15000 }, | ||
}, options); | ||
...options, | ||
}; | ||
@@ -67,0 +68,0 @@ // Try fetching the coverage from the coverage badge if any |
@@ -7,3 +7,3 @@ 'use strict'; | ||
const servicesSupportedTypesMap = { | ||
coveralls: ['github'], // Coveralls actually supports bitbucket but shields.io only supports github, see: https://github.com/badges/shields/issues/793 | ||
coveralls: ['github'], // Coveralls actually supports bitbucket but shields.io only supports github, see: https://github.com/badges/shields/issues/793 | ||
codeclimate: ['github', 'bitbucket', 'gitlab'], | ||
@@ -48,3 +48,8 @@ scrutinizer: ['github', 'bitbucket'], | ||
function request(url, options) { | ||
return got(url, Object.assign({}, options.got, { json: true })) | ||
options = { | ||
...options, | ||
json: true, | ||
}; | ||
return got(url, options) | ||
.then((response) => { | ||
@@ -51,0 +56,0 @@ const json = response.body; |
{ | ||
"name": "fetch-coverage", | ||
"version": "1.1.0", | ||
"description": "Fetch the code coverage from an open-source GIT repository, using a variety of well-known coverage services", | ||
"main": "index.js", | ||
"scripts": { | ||
"lint": "eslint '{*.js,test/**/*.js}' --ignore-pattern=test/coverage", | ||
"test": "mocha --bail", | ||
"test-cov": "istanbul cover --dir test/coverage _mocha -- && echo Coverage lies in test/coverage/lcov-report/index.html", | ||
"test-travis": "istanbul cover _mocha --report lcovonly -- && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/IndigoUnited/node-fetch-coverage/issues/" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/IndigoUnited/node-fetch-coverage.git" | ||
}, | ||
"version": "2.0.0", | ||
"keywords": [ | ||
@@ -28,23 +14,56 @@ "code", | ||
], | ||
"author": "IndigoUnited <hello@indigounited.com> (http://indigounited.com)", | ||
"author": "André Cruz <andre@moxy.studio>", | ||
"homepage": "https://github.com/moxystudio/node-fetch-coverage", | ||
"repository": { | ||
"type": "git", | ||
"url": "git@github.com:moxystudio/node-fetch-coverage.git" | ||
}, | ||
"license": "MIT", | ||
"files": [ | ||
"index.js", | ||
"lib" | ||
], | ||
"main": "index.js", | ||
"scripts": { | ||
"lint": "eslint .", | ||
"test": "jest --env node --coverage", | ||
"test-travis": "NOCK_BACK_MODE=lockdown npm test", | ||
"prerelease": "npm t && npm run lint", | ||
"release": "standard-version", | ||
"precommit": "lint-staged", | ||
"commitmsg": "commitlint -e $GIT_PARAMS" | ||
}, | ||
"standard-version": { | ||
"scripts": { | ||
"posttag": "git push --follow-tags origin master && npm publish" | ||
} | ||
}, | ||
"lint-staged": { | ||
"*.js": [ | ||
"eslint --fix --ignore-pattern test/fixtures", | ||
"git add" | ||
] | ||
}, | ||
"commitlint": { | ||
"extends": [ | ||
"@commitlint/config-conventional" | ||
] | ||
}, | ||
"dependencies": { | ||
"got": "^6.5.0", | ||
"got": "^9.2.2", | ||
"hosted-git-info": "^2.1.5", | ||
"lodash.find": "^4.6.0", | ||
"require-directory": "^2.1.1" | ||
}, | ||
"devDependencies": { | ||
"@satazor/eslint-config": "^3.0.0", | ||
"chai": "^3.4.1", | ||
"coveralls": "^2.11.6", | ||
"eslint": "^3.0.0", | ||
"istanbul": "^0.4.1", | ||
"lodash": "^4.15.0", | ||
"mocha": "^3.0.0", | ||
"nock": "^9.0.2" | ||
}, | ||
"engines": { | ||
"node": ">=4.0.0" | ||
"@commitlint/cli": "^7.0.0", | ||
"@commitlint/config-conventional": "^7.0.0", | ||
"eslint": "^5.3.0", | ||
"eslint-config-moxy": "^6.0.1", | ||
"husky": "^0.14.0", | ||
"jest": "^23.4.1", | ||
"jest-serializer-path": "^0.1.15", | ||
"lint-staged": "^7.2.0", | ||
"standard-version": "^4.4.0", | ||
"nock": "^10.0.0" | ||
} | ||
} |
# fetch-coverage | ||
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coverage Status][coveralls-image]][coveralls-url] [![Dependency status][david-dm-image]][david-dm-url] [![Dev Dependency status][david-dm-dev-image]][david-dm-dev-url] | ||
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coverage Status][codecov-image]][codecov-url] [![Dependency status][david-dm-image]][david-dm-url] [![Dev Dependency status][david-dm-dev-image]][david-dm-dev-url] [![Greenkeeper badge][greenkeeper-image]][greenkeeper-url] | ||
@@ -8,10 +8,12 @@ [npm-url]:https://npmjs.org/package/fetch-coverage | ||
[npm-image]:http://img.shields.io/npm/v/fetch-coverage.svg | ||
[travis-url]:https://travis-ci.org/IndigoUnited/node-fetch-coverage | ||
[travis-image]:http://img.shields.io/travis/IndigoUnited/node-fetch-coverage/master.svg | ||
[coveralls-url]:https://coveralls.io/r/IndigoUnited/node-fetch-coverage | ||
[coveralls-image]:https://img.shields.io/coveralls/IndigoUnited/node-fetch-coverage/master.svg | ||
[david-dm-url]:https://david-dm.org/IndigoUnited/node-fetch-coverage | ||
[david-dm-image]:https://img.shields.io/david/IndigoUnited/node-fetch-coverage.svg | ||
[david-dm-dev-url]:https://david-dm.org/IndigoUnited/node-fetch-coverage#info=devDependencies | ||
[david-dm-dev-image]:https://img.shields.io/david/dev/IndigoUnited/node-fetch-coverage.svg | ||
[travis-url]:https://travis-ci.org/moxystudio/node-fetch-coverage | ||
[travis-image]:http://img.shields.io/travis/moxystudio/node-fetch-coverage/master.svg | ||
[codecov-url]:https://codecov.io/gh/moxystudio/node-fetch-coverage | ||
[codecov-image]:https://img.shields.io/codecov/c/github/moxystudio/node-fetch-coverage/master.svg | ||
[david-dm-url]:https://david-dm.org/moxystudio/node-fetch-coverage | ||
[david-dm-image]:https://img.shields.io/david/moxystudio/node-fetch-coverage.svg | ||
[david-dm-dev-url]:https://david-dm.org/moxystudio/node-fetch-coverage?type=dev | ||
[david-dm-dev-image]:https://img.shields.io/david/dev/moxystudio/node-fetch-coverage.svg | ||
[greenkeeper-image]:https://badges.greenkeeper.io/moxystudio/node-fetch-coverage.svg | ||
[greenkeeper-url]:https://greenkeeper.io/ | ||
@@ -27,3 +29,5 @@ Fetch the code coverage from an open-source GIT repository, using a variety of well-known coverage services. | ||
`$ npm install fetch-coverage` | ||
```sh | ||
$ npm install fetch-coverage | ||
``` | ||
@@ -38,3 +42,3 @@ | ||
fetchCoverage('git@github.com:IndigoUnited/node-planify.git') | ||
fetchCoverage('git@github.com:moxystudio/node-planify.git') | ||
// `coverage` is a number between 0 and 1 or `null` if there's no code coverage | ||
@@ -56,4 +60,6 @@ .then((coverage) => console.log('Coverage', coverage)); | ||
`$ npm test` | ||
`$ npm test-cov` to get coverage report | ||
```sh | ||
$ npm test | ||
$ npm test -- --watch # during development | ||
``` | ||
@@ -60,0 +66,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
3
0
66
11561
10
10
137
1
2
+ Added@sindresorhus/is@0.14.0(transitive)
+ Added@szmarczak/http-timer@1.1.2(transitive)
+ Addedcacheable-request@6.1.0(transitive)
+ Addedclone-response@1.0.3(transitive)
+ Addeddecompress-response@3.3.0(transitive)
+ Addeddefer-to-connect@1.1.3(transitive)
+ Addedend-of-stream@1.4.4(transitive)
+ Addedget-stream@4.1.05.2.0(transitive)
+ Addedgot@9.6.0(transitive)
+ Addedhttp-cache-semantics@4.1.1(transitive)
+ Addedjson-buffer@3.0.0(transitive)
+ Addedkeyv@3.1.0(transitive)
+ Addedlowercase-keys@2.0.0(transitive)
+ Addedmimic-response@1.0.1(transitive)
+ Addednormalize-url@4.5.1(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedp-cancelable@1.1.0(transitive)
+ Addedprepend-http@2.0.0(transitive)
+ Addedpump@3.0.2(transitive)
+ Addedresponselike@1.0.2(transitive)
+ Addedto-readable-stream@1.0.0(transitive)
+ Addedurl-parse-lax@3.0.0(transitive)
+ Addedwrappy@1.0.2(transitive)
- Removedlodash.find@^4.6.0
- Removedcapture-stack-trace@1.0.2(transitive)
- Removedcreate-error-class@3.0.2(transitive)
- Removedget-stream@3.0.0(transitive)
- Removedgot@6.7.1(transitive)
- Removedis-redirect@1.0.0(transitive)
- Removedis-retry-allowed@1.2.0(transitive)
- Removedis-stream@1.1.0(transitive)
- Removedlodash.find@4.6.0(transitive)
- Removedprepend-http@1.0.4(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedtimed-out@4.0.1(transitive)
- Removedunzip-response@2.0.1(transitive)
- Removedurl-parse-lax@1.0.0(transitive)
Updatedgot@^9.2.2