diff --git a/README.md b/README.md index d105857..88d78f2 100644 --- a/README.md +++ b/README.md @@ -27,13 +27,13 @@ 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` @@ -41,21 +41,22 @@ Currently just reads from Istanbul's JSON summary reporter and downloads a badge Resulting badge will be in `./coverage/badge.svg`. ## Options -#### `make-coverage-badge --outputPath ` -Creates the svg at the specified path (relative to project root). Defaults to `./coverage/badge.svg`. +### `--output-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 (https://tlvince.com) +© 2019 Tom Vincent (https://tlvince.com) ## License diff --git a/cli.js b/cli.js index 6e9097e..6ea4f5c 100755 --- a/cli.js +++ b/cli.js @@ -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) { @@ -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 diff --git a/package-lock.json b/package-lock.json index dc4b836..fc8b092 100644 --- a/package-lock.json +++ b/package-lock.json @@ -395,15 +395,6 @@ "integrity": "sha1-oMoMvCmltz6Dbuvhy/bF4OTrgvk=", "dev": true }, - "argv-tools": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/argv-tools/-/argv-tools-0.1.1.tgz", - "integrity": "sha512-Cc0dBvx4dvrjjKpyDA6w8RlNAw8Su30NvZbWl/Tv9ZALEVlLVkWQiHMi84Q0xNfpVuSaiQbYkdmWK8g1PLGhKw==", - "requires": { - "array-back": "^2.0.0", - "find-replace": "^2.0.1" - } - }, "arr-diff": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", @@ -422,14 +413,6 @@ "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", "dev": true }, - "array-back": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/array-back/-/array-back-2.0.0.tgz", - "integrity": "sha512-eJv4pLLufP3g5kcZry0j6WXpIbzYw9GUB4mVJZno9wfwiBxbizTnHCw3VJb07cBihbFX48Y7oSrW9y+gt4glyw==", - "requires": { - "typical": "^2.6.1" - } - }, "array-find-index": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/array-find-index/-/array-find-index-1.0.2.tgz", @@ -925,18 +908,6 @@ "integrity": "sha1-JCP+ZnisDF2uiFLl0OW+CMmXq8w=", "dev": true }, - "command-line-args": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/command-line-args/-/command-line-args-5.0.2.tgz", - "integrity": "sha512-/qPcbL8zpqg53x4rAaqMFlRV4opN3pbla7I7k9x8kyOBMQoGT6WltjN6sXZuxOXw6DgdK7Ad+ijYS5gjcr7vlA==", - "requires": { - "argv-tools": "^0.1.1", - "array-back": "^2.0.0", - "find-replace": "^2.0.1", - "lodash.camelcase": "^4.3.0", - "typical": "^2.6.1" - } - }, "commander": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/commander/-/commander-2.1.0.tgz", @@ -1918,15 +1889,6 @@ "integrity": "sha1-M8RLQpqysvBkYpnF+fcY83b/jVQ=", "dev": true }, - "find-replace": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/find-replace/-/find-replace-2.0.1.tgz", - "integrity": "sha512-LzDo3Fpa30FLIBsh6DCDnMN1KW2g4QKkqKmejlImgWY67dDFPX/x9Kh/op/GK522DchQXEvDi/wD48HKW49XOQ==", - "requires": { - "array-back": "^2.0.0", - "test-value": "^3.0.0" - } - }, "find-root": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", @@ -2951,11 +2913,6 @@ "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=", "dev": true }, - "lodash.camelcase": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz", - "integrity": "sha1-soqmKIorn8ZRA1x3EfZathkDMaY=" - }, "lodash.capitalize": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/lodash.capitalize/-/lodash.capitalize-4.2.1.tgz", @@ -7940,15 +7897,6 @@ } } }, - "test-value": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/test-value/-/test-value-3.0.0.tgz", - "integrity": "sha512-sVACdAWcZkSU9x7AOmJo5TqE+GyNJknHaHsMrR6ZnhjVlVN9Yx6FjHrsKZ3BjIpPCT68zYesPWkakrNupwfOTQ==", - "requires": { - "array-back": "^2.0.0", - "typical": "^2.6.1" - } - }, "text-extensions": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/text-extensions/-/text-extensions-1.9.0.tgz", @@ -8087,11 +8035,6 @@ "prelude-ls": "~1.1.2" } }, - "typical": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/typical/-/typical-2.6.1.tgz", - "integrity": "sha1-XAgOXWYcu+OCWdLnCjxyU+hziB0=" - }, "uglify-js": { "version": "3.4.10", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.4.10.tgz", diff --git a/package.json b/package.json index d71798c..a996563 100644 --- a/package.json +++ b/package.json @@ -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",