Skip to content

Commit

Permalink
fix: zero-dependencies, add --output-path alias
Browse files Browse the repository at this point in the history
Alias `--outputPath` to `--output-path`
  • Loading branch information
tlvince committed Mar 16, 2019
1 parent 67f86e2 commit 10d70ee
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 84 deletions.
27 changes: 14 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,35 +27,36 @@ Currently just reads from Istanbul's JSON summary reporter and downloads a badge

1. Configure Jest (in `package.json`):

```json
"jest": {
"coverageReporters": [
"json-summary"
]
}
```
```json
"jest": {
"coverageReporters": [
"json-summary"
]
}
```

2. Run `npm test -- --coverage`
3. Run `make-coverage-badge`

Resulting badge will be in `./coverage/badge.svg`.

## Options
#### `make-coverage-badge --outputPath <path...>`

Creates the svg at the specified path (relative to project root). Defaults to `./coverage/badge.svg`.
### `--output-path <path>`

Writes the coverage badge to the given path (relative to project root). Defaults to `./coverage/badge.svg`.

## Prior work

* [Coveralls][]: paid for private repos
* [coverage-badger][]: same approach, but using an XML report and therefore requires XML dependencies
- [Coveralls][]: paid for private repos
- [coverage-badger][]: same approach, but using an XML report and therefore requires XML dependencies

[Coveralls]: https://coveralls.io/
[coveralls]: https://coveralls.io/
[coverage-badger]: https://github.com/notnotse/coverage-badger

## Author

© 2017 Tom Vincent <[email protected]> (https://tlvince.com)
© 2019 Tom Vincent <[email protected]> (https://tlvince.com)

## License

Expand Down
13 changes: 2 additions & 11 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

const { get } = require('https')
const { readFile, writeFile } = require('fs')
const commandLineArgs = require('command-line-args')

const getColour = coverage => {
if (coverage < 80) {
Expand Down Expand Up @@ -33,16 +32,8 @@ const download = (url, cb) => {
}).on('error', err => cb(err))
}

// Parse command line arguments
const argumentDefinitions = [
{
name: 'outputPath',
type: String,
defaultOption: true
}
]
const args = commandLineArgs(argumentDefinitions)
const outputPath = args.outputPath || './coverage/badge.svg'
const [, , thirdArg, fourthArg] = process.argv
const outputPath = ((thirdArg === '--output-path' || thirdArg === '--outputPath') && fourthArg) ? fourthArg : './coverage/badge.svg'

readFile('./coverage/coverage-summary.json', 'utf8', (err, res) => {
if (err) throw err
Expand Down
57 changes: 0 additions & 57 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@
"url": "https://github.com/tlvince/make-coverage-badge/issues"
},
"homepage": "https://github.com/tlvince/make-coverage-badge#readme",
"dependencies": {
"command-line-args": "5.0.2"
},
"devDependencies": {
"husky": "1.3.1",
"semantic-release": "15.13.3",
Expand Down

0 comments on commit 10d70ee

Please sign in to comment.