Skip to content
This repository was archived by the owner on Feb 20, 2019. It is now read-only.

Commit 5c5aba3

Browse files
author
Kent C. Dodds
committed
chore(coverage): Add code coverage support
So I can use code coverage checking in the githooks to demonstrate --no-verify
1 parent 8e4543c commit 5c5aba3

File tree

6 files changed

+15
-5
lines changed

6 files changed

+15
-5
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
dist
22
node_modules
3+
.nyc_output/
4+
coverage/

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ before_install:
1515
before_script:
1616
- npm prune
1717
script:
18-
- npm t
18+
- npm run cover
1919
- npm run build
2020
after_success:
2121
- npm run semantic-release
22+
- npm run report-coverage

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ that I'll accept it before you spend time working on it.
4040
5. Run `npm t && npm run build`. If everything works, then you're ready to make changes.
4141
6. Run `npm run test:watch`. See that it's watching your file system for changes.
4242
7. Make your changes and try to make the tests pass. If you can't or need help then commit what you have with `--no-verify` and make a PR
43-
8. If you get things working, add your changed files with `git add` and run `npm run commit` to get an interactive prompt for creating a commit message that follows [our standards](https://github.com/ajoslin/conventional-changelog/blob/master/conventions/angular.md)
43+
8. If you get things working, add your changed files with `git add` and run `npm run commit` to get an interactive prompt for creating a commit message that follows [our standards](https://github.com/ajoslin/conventional-changelog/blob/master/conventions/angular.md). You'll notice that there are git hooks in place which will run testing, linting, etc. (unless you commit with `--no-verify`).
4444
9. Push your changes to your fork with `git push`
4545
10. Create a pull request.
4646
11. Iterate on the solution.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# stack-overflow-copy-paste
22

33
[![travis build](https://img.shields.io/travis/eggheadio-github/stack-overflow-copy-paste.svg?style=flat-square)](https://travis-ci.org/eggheadio-github/stack-overflow-copy-paste)
4+
[![codecov coverage](https://img.shields.io/codecov/c/github/eggheadio-github/stack-overflow-copy-paste.svg?style=flat-square)](https://codecov.io/github/eggheadio-github/stack-overflow-copy-paste)
45
[![version](https://img.shields.io/npm/v/stack-overflow-copy-paste.svg?style=flat-square)](http://npm.im/stack-overflow-copy-paste)
56
[![downloads](https://img.shields.io/npm/dm/stack-overflow-copy-paste.svg?style=flat-square)](http://npm-stat.com/charts.html?package=stack-overflow-copy-paste&from=2015-08-01)
67
[![MIT License](https://img.shields.io/npm/l/stack-overflow-copy-paste.svg?style=flat-square)](http://opensource.org/licenses/MIT)

package.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@
77
"commit": "git-cz",
88
"prebuild": "npm run lint && npm run clean",
99
"clean": "rimraf dist && mkdir dist",
10+
"cover": "nyc --reporter lcov --reporter text npm t",
11+
"check-coverage": "nyc check-coverage --statements 100 --branches 100 --functions 100 --lines 100",
12+
"report-coverage": "cat ./coverage/lcov.info | codecov",
1013
"build": "babel src/ -d dist/",
1114
"test": "ava --require babel-register",
15+
"test:watch": "nodemon --exec npm t",
1216
"lint": "eslint src/",
1317
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
1418
},
@@ -38,14 +42,15 @@
3842
"eslint-config-kentcdodds": "5.0.1",
3943
"ghooks": "1.0.3",
4044
"nodemon": "1.8.1",
45+
"nyc": "5.3.0",
4146
"rimraf": "2.5.0",
42-
"validate-commit-msg": "1.1.1",
43-
"semantic-release": "4.3.5"
47+
"semantic-release": "4.3.5",
48+
"validate-commit-msg": "1.1.1"
4449
},
4550
"config": {
4651
"ghooks": {
4752
"commit-msg": "validate-commit-msg",
48-
"pre-commit": "npm t && npm run build"
53+
"pre-commit": "npm run cover && npm run check-coverage && npm run build"
4954
},
5055
"commitizen": {
5156
"path": "node_modules/cz-conventional-changelog"

src/flatten.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ function flatten(arr) {
55
return flat.concat(Array.isArray(toFlatten) ? flatten(toFlatten) : toFlatten)
66
}, [])
77
}
8+

0 commit comments

Comments
 (0)