Skip to content

Commit 017a26b

Browse files
committed
chore: upgrade project
BREAKING CHANGE: only node >= v8 is supported
1 parent 23a40c4 commit 017a26b

12 files changed

+9406
-220
lines changed

.editorconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ charset = utf-8
88
trim_trailing_whitespace = true
99
insert_final_newline = true
1010

11-
[*.md]
11+
[{*.md,*.snap}]
1212
trim_trailing_whitespace = false
1313

1414
[package.json]

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
coverage/

.eslintrc.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"root": true,
33
"extends": [
4-
"@satazor/eslint-config/es6",
5-
"@satazor/eslint-config/addons/node",
6-
"@satazor/eslint-config/addons/node-v4-es6"
4+
"eslint-config-moxy/es9",
5+
"eslint-config-moxy/addons/node",
6+
"eslint-config-moxy/addons/jest"
77
]
88
}

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
node_modules
22
npm-debug.*
3-
test/coverage
3+
coverage/

README.md

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# fetch-coverage
22

3-
[![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] [![Greenkeeper badge][greenkeeper-image]][greenkeeper-url]
3+
[![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]
44

55
[npm-url]:https://npmjs.org/package/fetch-coverage
66
[downloads-image]:http://img.shields.io/npm/dm/fetch-coverage.svg
77
[npm-image]:http://img.shields.io/npm/v/fetch-coverage.svg
88
[travis-url]:https://travis-ci.org/IndigoUnited/node-fetch-coverage
99
[travis-image]:http://img.shields.io/travis/IndigoUnited/node-fetch-coverage/master.svg
10-
[coveralls-url]:https://coveralls.io/r/IndigoUnited/node-fetch-coverage
11-
[coveralls-image]:https://img.shields.io/coveralls/IndigoUnited/node-fetch-coverage/master.svg
10+
[codecov-url]:https://codecov.io/gh/moxystudio/node-fetch-coverage
11+
[codecov-image]:https://img.shields.io/codecov/c/github/moxystudio/node-fetch-coverage/master.svg
1212
[david-dm-url]:https://david-dm.org/IndigoUnited/node-fetch-coverage
1313
[david-dm-image]:https://img.shields.io/david/IndigoUnited/node-fetch-coverage.svg
1414
[david-dm-dev-url]:https://david-dm.org/IndigoUnited/node-fetch-coverage?type=dev
@@ -25,7 +25,9 @@ Feel free to make a PR adding support for another coverage service.
2525

2626
## Installation
2727

28-
`$ npm install fetch-coverage`
28+
```sh
29+
$ npm install fetch-coverage
30+
```
2931

3032

3133
## Usage
@@ -52,8 +54,10 @@ Available options:
5254

5355
## Tests
5456

55-
`$ npm test`
56-
`$ npm test-cov` to get coverage report
57+
```sh
58+
$ npm test
59+
$ npm test -- --watch # during development
60+
```
5761

5862

5963
## License

index.js

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
'use strict';
22

33
const hostedGitInfo = require('hosted-git-info');
4-
const find = require('lodash.find');
54
const fetchers = require('require-directory')(module, './lib', { recurse: false });
65
const shieldsIo = require('./lib/util/shieldsIo');
76

87
function tryBadges(options) {
9-
const coverageBadge = find(options.badges, (badge) => badge.info.type === 'coverage');
8+
const coverageBadge = options.badges && options.badges.find((badge) => badge.info.type === 'coverage');
109
const shieldsIoUrl = coverageBadge && coverageBadge.urls.content;
1110

1211
return shieldsIoUrl ? shieldsIo.request(shieldsIoUrl, options) : Promise.resolve(false);
@@ -15,14 +14,14 @@ function tryBadges(options) {
1514
function tryServices(gitInfo, options) {
1615
const errors = [];
1716

18-
const promises = options.services.map((service) => {
19-
return fetchers[service] && fetchers[service](gitInfo, options)
20-
.catch((err) => { errors.push(err); });
21-
});
17+
const promises = options.services.map((service) =>
18+
fetchers[service] && fetchers[service](gitInfo, options)
19+
.catch((err) => { errors.push(err); })
20+
);
2221

2322
return Promise.all(promises)
2423
.then((coverages) => {
25-
const coverage = find(coverages, (coverage) => coverage != null);
24+
const coverage = coverages.find((coverage) => coverage != null);
2625

2726
if (coverage != null) {
2827
return coverage;
@@ -46,19 +45,21 @@ function fetchCoverage(repositoryUrl, options) {
4645
try {
4746
gitInfo = hostedGitInfo.fromUrl(repositoryUrl);
4847
} catch (err) {
49-
return Promise.resolve(null);
48+
/* istanbul ignore next */
49+
return null;
5050
}
5151

5252
if (!gitInfo) {
53-
return Promise.resolve(null);
53+
return null;
5454
}
5555

56-
options = Object.assign({
56+
options = {
5757
branch: null,
5858
badges: null,
5959
services: ['codecov', 'coveralls', 'codeclimate', 'scrutinizer'],
6060
got: { timeout: 15000 },
61-
}, options);
61+
...options,
62+
};
6263

6364
// Try fetching the coverage from the coverage badge if any
6465
return tryBadges(options)

lib/util/shieldsIo.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const got = require('got');
44

55
// Mapping that associates the repository type with the services
66
const servicesSupportedTypesMap = {
7-
coveralls: ['github'], // Coveralls actually supports bitbucket but shields.io only supports github, see: https://github.com/badges/shields/issues/793
7+
coveralls: ['github'], // Coveralls actually supports bitbucket but shields.io only supports github, see: https://github.com/badges/shields/issues/793
88
codeclimate: ['github', 'bitbucket', 'gitlab'],
99
scrutinizer: ['github', 'bitbucket'],
1010
codecov: ['github', 'bitbucket', 'gitlab'],
@@ -44,7 +44,12 @@ function getUrl(gitInfo, service, options) {
4444
// -------------------------------------------
4545

4646
function request(url, options) {
47-
return got(url, Object.assign({}, options.got, { json: true }))
47+
options = {
48+
...options,
49+
json: true,
50+
};
51+
52+
return got(url, options)
4853
.then((response) => {
4954
const json = response.body;
5055

0 commit comments

Comments
 (0)