mirror of
https://github.com/badgen/badgen-cli.git
synced 2025-04-19 05:22:20 +03:00
First commit 🎉
This commit is contained in:
parent
a03fe524c1
commit
2adee88543
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
.idea/
|
||||
.nyc_output/
|
||||
node_modules/
|
78
cli.js
Executable file
78
cli.js
Executable file
@ -0,0 +1,78 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const meow = require('meow')
|
||||
const badgen = require('badgen')
|
||||
const icons = require('badgen-icons')
|
||||
|
||||
const flags = {
|
||||
status: {
|
||||
type: 'string',
|
||||
alias: 's'
|
||||
},
|
||||
subject: {
|
||||
type: 'string',
|
||||
alias: 'j',
|
||||
default: ''
|
||||
},
|
||||
color: {
|
||||
type: 'string',
|
||||
alias: 'c'
|
||||
},
|
||||
flat: {
|
||||
type: 'boolean',
|
||||
alias: 'f'
|
||||
},
|
||||
icon: {
|
||||
type: 'string',
|
||||
alias: 'i'
|
||||
},
|
||||
iconWidth: {
|
||||
type: 'string',
|
||||
alias: 'w'
|
||||
}
|
||||
}
|
||||
|
||||
const cli = meow(`
|
||||
Usage
|
||||
$ badgen <options>
|
||||
|
||||
Options
|
||||
--status, -s (required) Status of the badge, right part
|
||||
--subject, -j Subject of the badge, left part
|
||||
--color, -c Color of the status
|
||||
--flat, -f Use the flat badge style
|
||||
--icon, -i Icon to use
|
||||
--icon-width, -w Width of the icon if not square
|
||||
|
||||
Example
|
||||
$ badgen --subject test --status ok --color green --icon terminal --flat > test.svg
|
||||
`, {
|
||||
flags
|
||||
})
|
||||
|
||||
const options = {}
|
||||
|
||||
// Normalize flag to keep the last override
|
||||
// Might be unnecessary when https://github.com/sindresorhus/meow/issues/111 is resolved
|
||||
Object.keys(flags).forEach(key => {
|
||||
let flag = cli.flags[key]
|
||||
|
||||
if (Array.isArray(flag)) {
|
||||
flag = flag[flag.length - 1]
|
||||
}
|
||||
|
||||
options[key] = flag
|
||||
})
|
||||
|
||||
options.style = options.flat && 'flat'
|
||||
|
||||
const icon = icons[options.icon === '' ? options.subject : options.icon]
|
||||
options.icon = icon && icon.base64 || ''
|
||||
options.iconWidth = options.iconWidth || icon && icon.width || null
|
||||
|
||||
try {
|
||||
const svg = badgen(options)
|
||||
console.log(svg)
|
||||
} catch (error) {
|
||||
console.error(error.message)
|
||||
}
|
6229
package-lock.json
generated
Normal file
6229
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
37
package.json
Normal file
37
package.json
Normal file
@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "badgen-cli",
|
||||
"version": "0.0.1",
|
||||
"description": "",
|
||||
"keywords": [
|
||||
"cli",
|
||||
"badge",
|
||||
"svg"
|
||||
],
|
||||
"bin": {
|
||||
"badgen": "cli.js"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "standart",
|
||||
"test": "tap"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/badgen/badgen-cli.git"
|
||||
},
|
||||
"author": "GMartigny <guillaume.martigny@gmail.com>",
|
||||
"license": "ISC",
|
||||
"bugs": {
|
||||
"url": "https://github.com/badgen/badgen-cli/issues"
|
||||
},
|
||||
"homepage": "https://github.com/badgen/badgen-cli#readme",
|
||||
"dependencies": {
|
||||
"badgen": "^2.7.1",
|
||||
"badgen-icons": "^0.8.0",
|
||||
"meow": "^5.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"execa": "^1.0.0",
|
||||
"standart": "^6.1.0",
|
||||
"tap": "^13.1.2"
|
||||
}
|
||||
}
|
34
readme.md
Normal file
34
readme.md
Normal file
@ -0,0 +1,34 @@
|
||||
# Badgen-cli
|
||||
|
||||
Use the fastest badge generator from your CLI.
|
||||
|
||||
## Installation
|
||||
|
||||
$ npm install -g badgen-cli
|
||||
|
||||
## Usage
|
||||
|
||||
$ badgen --subject build --status ok --color green > build-ok.svg
|
||||
|
||||
## Options
|
||||
|
||||
* `--status`, `-s`<br>
|
||||
(required) String, Right-hand side of the badge
|
||||
* `--subject`, `-j`<br>
|
||||
String, left-hand side of the badge
|
||||
* `--color`, `-c`<br>
|
||||
String, color for the status (color name or RGB hexa value)
|
||||
* `--flat`, `-f`<br>
|
||||
Boolean, use the flat style badge
|
||||
* `--icon`, `-i`<br>
|
||||
String, icon before the subject (icon name, image data URI or inferred from the subject)
|
||||
* `--icon-width`, `-w`<br>
|
||||
Number, width of the icon if not square
|
||||
|
||||
## See also
|
||||
|
||||
[Badgen](https://github.com/badgen/badgen), the module behind this CLI.
|
||||
|
||||
## License
|
||||
|
||||
[ISC](license)
|
164
tap-snapshots/test-index.spec.js-TAP.test.js
Normal file
164
tap-snapshots/test-index.spec.js-TAP.test.js
Normal file
@ -0,0 +1,164 @@
|
||||
/* IMPORTANT
|
||||
* This snapshot file is auto-generated, but designed for humans.
|
||||
* It should be checked into source control and tracked carefully.
|
||||
* Re-generate by setting TAP_SNAPSHOT=1 and running tests.
|
||||
* Make sure to inspect the output below. Do not ignore changes!
|
||||
*/
|
||||
'use strict'
|
||||
exports[`test/index.spec.js TAP Assert icon from subject > Assert icon from subject 1`] = `
|
||||
<svg width="90.9" height="20" viewBox="0 0 909 200" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<linearGradient id="a" x2="0" y2="100%">
|
||||
<stop offset="0" stop-opacity=".1" stop-color="#EEE"/>
|
||||
<stop offset="1" stop-opacity=".1"/>
|
||||
</linearGradient>
|
||||
<mask id="m"><rect width="909" height="200" rx="30" fill="#FFF"/></mask>
|
||||
<g mask="url(#m)">
|
||||
<rect width="677" height="200" fill="#555"/>
|
||||
<rect width="232" height="200" fill="#08C" x="677"/>
|
||||
<rect width="909" height="200" fill="url(#a)"/>
|
||||
</g>
|
||||
<g fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||
<text x="220" y="148" textLength="417" fill="#000" opacity="0.25">chrome</text>
|
||||
<text x="210" y="138" textLength="417">chrome</text>
|
||||
<text x="732" y="148" textLength="132" fill="#000" opacity="0.25">ok</text>
|
||||
<text x="722" y="138" textLength="132">ok</text>
|
||||
</g>
|
||||
<image x="40" y="35" width="130" height="130" xlink:href="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9IiNGRkYiIHZpZXdCb3g9IjAgMCAyNCAyNCI+CiAgPHBhdGggZD0iTTE2LjIxIDguNjlsNi43Mi0xLjY4QTEyLjAzIDEyLjAzIDAgMCAxIDI0IDExLjk3YTEyLjA5IDEyLjA5IDAgMCAxLTEyLjk0IDEybDQuOS04LjM1Yy4zNi0uMzguNjYtLjguODktMS4yN2E1LjQ1IDUuNDUgMCAwIDAtLjA1LTQuNzUgNS4xNiA1LjE2IDAgMCAwLS41OS0uOTF6bS0zLjI0IDguNTdsLTIuMTIgNi42OUExMi4wMiAxMi4wMiAwIDAgMSAyLjA0IDUuMjhsNC44MyA4LjM4Yy4xOC41NCAxLjEyIDIuNTggMy4wNyAzLjMyIDEgLjM5IDIuMDQuNDggMy4wMy4yOXptLTEtOS42NGE0LjUyIDQuNTIgMCAwIDAtNC4yOCAzLjUxIDQuNDggNC40OCAwIDAgMCAxLjI0IDQuMDMgNC40OSA0LjQ5IDAgMCAwIDQuNzMuOTMgNC40OSA0LjQ5IDAgMCAwIDIuNy0zLjQzIDQuNTMgNC41MyAwIDAgMC0yLjUtNC42MyA0LjQxIDQuNDEgMCAwIDAtMS44OS0uNDF6TTcuMDUgOS45NmwtNC44LTVBMTIuMDQgMTIuMDQgMCAwIDEgMTIgMGM0LjU2IDAgOC43NCAyLjYgMTAuNzcgNi42N0gxMi41NmE1LjU0IDUuNTQgMCAwIDAtNC4yNyAxLjQ2IDUuMzQgNS4zNCAwIDAgMC0xLjI0IDEuODN6Ii8+Cjwvc3ZnPgo="/>
|
||||
</svg>
|
||||
`
|
||||
|
||||
exports[`test/index.spec.js TAP Override properties > Override properties 1`] = `
|
||||
<svg width="54.1" height="20" viewBox="0 0 541 200" xmlns="http://www.w3.org/2000/svg">
|
||||
<linearGradient id="a" x2="0" y2="100%">
|
||||
<stop offset="0" stop-opacity=".1" stop-color="#EEE"/>
|
||||
<stop offset="1" stop-opacity=".1"/>
|
||||
</linearGradient>
|
||||
<mask id="m"><rect width="541" height="200" rx="30" fill="#FFF"/></mask>
|
||||
<g mask="url(#m)">
|
||||
<rect width="309" height="200" fill="#555"/>
|
||||
<rect width="232" height="200" fill="#3C1" x="309"/>
|
||||
<rect width="541" height="200" fill="url(#a)"/>
|
||||
</g>
|
||||
<g fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||
<text x="60" y="148" textLength="209" fill="#000" opacity="0.25">test</text>
|
||||
<text x="50" y="138" textLength="209">test</text>
|
||||
<text x="364" y="148" textLength="132" fill="#000" opacity="0.25">ok</text>
|
||||
<text x="354" y="138" textLength="132">ok</text>
|
||||
</g>
|
||||
|
||||
</svg>
|
||||
`
|
||||
|
||||
exports[`test/index.spec.js TAP Status and color > Status and color 1`] = `
|
||||
<svg width="24.7" height="20" viewBox="0 0 247 200" xmlns="http://www.w3.org/2000/svg">
|
||||
<linearGradient id="a" x2="0" y2="100%">
|
||||
<stop offset="0" stop-opacity=".1" stop-color="#EEE"/>
|
||||
<stop offset="1" stop-opacity=".1"/>
|
||||
</linearGradient>
|
||||
<mask id="m"><rect width="247" height="200" rx="30" fill="#FFF"/></mask>
|
||||
<g mask="url(#m)">
|
||||
<rect width="247" height="200" fill="#E43" x="0"/>
|
||||
<rect width="247" height="200" fill="url(#a)"/>
|
||||
</g>
|
||||
<g fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||
<text x="65" y="148" textLength="132" fill="#000" opacity="0.25">ok</text>
|
||||
<text x="55" y="138" textLength="132">ok</text>
|
||||
</g>
|
||||
</svg>
|
||||
`
|
||||
|
||||
exports[`test/index.spec.js TAP Status and flat > Status and flat 1`] = `
|
||||
<svg width="24.7" height="20" viewBox="0 0 247 200" xmlns="http://www.w3.org/2000/svg">
|
||||
<g>
|
||||
<rect fill="#08C" x="0" width="247" height="200"/>
|
||||
</g>
|
||||
<g fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||
<text x="65" y="148" textLength="132" fill="#000" opacity="0.1">ok</text>
|
||||
<text x="55" y="138" textLength="132">ok</text>
|
||||
</g>
|
||||
</svg>
|
||||
`
|
||||
|
||||
exports[`test/index.spec.js TAP Status and icon > Status and icon 1`] = `
|
||||
<svg width="44.4" height="20" viewBox="0 0 444 200" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<linearGradient id="a" x2="0" y2="100%">
|
||||
<stop offset="0" stop-opacity=".1" stop-color="#EEE"/>
|
||||
<stop offset="1" stop-opacity=".1"/>
|
||||
</linearGradient>
|
||||
<mask id="m"><rect width="444" height="200" rx="30" fill="#FFF"/></mask>
|
||||
<g mask="url(#m)">
|
||||
<rect width="212" height="200" fill="#555"/>
|
||||
<rect width="232" height="200" fill="#08C" x="212"/>
|
||||
<rect width="444" height="200" fill="url(#a)"/>
|
||||
</g>
|
||||
<g fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||
<text x="172" y="148" textLength="0" fill="#000" opacity="0.25"></text>
|
||||
<text x="162" y="138" textLength="0"></text>
|
||||
<text x="267" y="148" textLength="132" fill="#000" opacity="0.25">ok</text>
|
||||
<text x="257" y="138" textLength="132">ok</text>
|
||||
</g>
|
||||
<image x="40" y="35" width="130" height="130" xlink:href="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyODcgMjg3Ij4KICA8ZyB0cmFuc2Zvcm09InRyYW5zbGF0ZSgyMCwwKSI+CiAgICA8cGF0aCBmaWxsPSIjNTU1IiBkPSJNNy45NiA3Mi4zNkwxMjkuNzEgMS40OGwxMjEuNzQgNzAuODh2MTQxLjY2TDEyOS43IDI4NC45IDcuOTYgMjE0LjAyVjcyLjM2eiIvPgogICAgPHBhdGggZmlsbD0iI0ZGRiIgZD0iTTEzMy4xMiAxNDMuMTNsMTEzLjItNjUuMiA0LjU2IDEzMS40Mi0xMTcuNzYgNzEuMTFWMTQzLjEzeiIvPgogICAgPHBhdGggZmlsbD0iIzU1NSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMjQ4LjA0IDczLjk2bC0uMzUgMTM5LjI2LTExOC4xIDY4LjUtLjU3LTEzNi44OCAxMTkuMDItNzAuODh6bS05OS4zMyA4Mi4yNmwuMzQgOTEuNDcgMzkuMjUtMjIuODctLjExLTY4Ljk0IDE5LjgtMTEuNzJ2NjkuMTdsMTkuOC0xMS42LjEtOTIuNjItNzkuMTggNDcuMXoiLz4KICAgIDxwYXRoIGZpbGw9IiNGRkYiIGQ9Ik0xMzcuNDQgMi41Yy01LjQ2LTMuMDctMTQuMjItMy4wNy0xOS42OCAwTDkuOSA2NC41MUM0LjQ0IDY3LjU4LjEgNzUuMzIuMSA4MS40NnYxMjQuMDJjMCA2LjI2IDQuNDQgMTMuODggOS43OSAxNi45NmwxMDcuODYgNjJjNS40NiAzLjA4IDE0LjIyIDMuMDggMTkuNjggMGwxMDcuODYtNjJjNS40Ny0zLjA4IDkuNzktMTAuODEgOS43OS0xNi45NlY4MS40N2MwLTYuMjYtNC40NC0xMy44OS05Ljc4LTE2Ljk2bC0xMDcuODctNjJ6bTk1LjcgNjQuODZjNS40NSAzLjA3IDUuNDUgOC4xOSAwIDExLjI2bC05NC40NSA1NC4yN2MtNS40NiAzLjA3LTE0LjIyIDMuMDctMTkuNjggMGwtOTUuOC01NS4wN2MtNS40Ni0zLjA3LTUuNDYtOC4xOSAwLTExLjI2bDk0LjQ0LTU0LjI3YzUuNDYtMy4wNyAxNC4yMi0zLjA3IDE5LjY4IDBsOTUuOCA1NS4wN3pNOC41MyA5MC40NmMwLTYuMjYgNC40My04Ljc3IDkuNzgtNS43bDk2LjYgNTUuNTNjNS40NiAzLjA3IDkuNzggMTAuOCA5Ljc4IDE2Ljk1djExMC4xNGMwIDYuMjYtNC40NCA4Ljc2LTkuNzggNS42OWwtOTYuNi01NS41M2MtNS40Ni0zLjA3LTkuNzktMTAuOC05Ljc5LTE2Ljk1VjkwLjQ1em0xMzQuNiAxODAuOWMtNS40NyAzLjA3LTkuOC41Ny05LjgtNS42OVYxNTcuMjRjMC02LjI2IDQuNDQtMTMuODggOS44LTE2Ljk1bDkzLjc0LTUzLjgyYzUuNDctMy4wNyA5Ljc5LS41NyA5Ljc5IDUuNjl2MTA4LjQzYzAgNi4yNi00LjQ0IDEzLjg4LTkuNzkgMTYuOTVsLTkzLjc1IDUzLjgyeiIvPgogIDwvZz4KPC9zdmc+Cg=="/>
|
||||
</svg>
|
||||
`
|
||||
|
||||
exports[`test/index.spec.js TAP Status only > Status only 1`] = `
|
||||
<svg width="24.7" height="20" viewBox="0 0 247 200" xmlns="http://www.w3.org/2000/svg">
|
||||
<linearGradient id="a" x2="0" y2="100%">
|
||||
<stop offset="0" stop-opacity=".1" stop-color="#EEE"/>
|
||||
<stop offset="1" stop-opacity=".1"/>
|
||||
</linearGradient>
|
||||
<mask id="m"><rect width="247" height="200" rx="30" fill="#FFF"/></mask>
|
||||
<g mask="url(#m)">
|
||||
<rect width="247" height="200" fill="#08C" x="0"/>
|
||||
<rect width="247" height="200" fill="url(#a)"/>
|
||||
</g>
|
||||
<g fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||
<text x="65" y="148" textLength="132" fill="#000" opacity="0.25">ok</text>
|
||||
<text x="55" y="138" textLength="132">ok</text>
|
||||
</g>
|
||||
</svg>
|
||||
`
|
||||
|
||||
exports[`test/index.spec.js TAP Subject and status > Subject and status 1`] = `
|
||||
<svg width="54.1" height="20" viewBox="0 0 541 200" xmlns="http://www.w3.org/2000/svg">
|
||||
<linearGradient id="a" x2="0" y2="100%">
|
||||
<stop offset="0" stop-opacity=".1" stop-color="#EEE"/>
|
||||
<stop offset="1" stop-opacity=".1"/>
|
||||
</linearGradient>
|
||||
<mask id="m"><rect width="541" height="200" rx="30" fill="#FFF"/></mask>
|
||||
<g mask="url(#m)">
|
||||
<rect width="309" height="200" fill="#555"/>
|
||||
<rect width="232" height="200" fill="#08C" x="309"/>
|
||||
<rect width="541" height="200" fill="url(#a)"/>
|
||||
</g>
|
||||
<g fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||
<text x="60" y="148" textLength="209" fill="#000" opacity="0.25">test</text>
|
||||
<text x="50" y="138" textLength="209">test</text>
|
||||
<text x="364" y="148" textLength="132" fill="#000" opacity="0.25">ok</text>
|
||||
<text x="354" y="138" textLength="132">ok</text>
|
||||
</g>
|
||||
|
||||
</svg>
|
||||
`
|
||||
|
||||
exports[`test/index.spec.js TAP Subject, status and icon > Subject, status and icon 1`] = `
|
||||
<svg width="70.1" height="20" viewBox="0 0 701 200" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<linearGradient id="a" x2="0" y2="100%">
|
||||
<stop offset="0" stop-opacity=".1" stop-color="#EEE"/>
|
||||
<stop offset="1" stop-opacity=".1"/>
|
||||
</linearGradient>
|
||||
<mask id="m"><rect width="701" height="200" rx="30" fill="#FFF"/></mask>
|
||||
<g mask="url(#m)">
|
||||
<rect width="469" height="200" fill="#555"/>
|
||||
<rect width="232" height="200" fill="#08C" x="469"/>
|
||||
<rect width="701" height="200" fill="url(#a)"/>
|
||||
</g>
|
||||
<g fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
|
||||
<text x="220" y="148" textLength="209" fill="#000" opacity="0.25">test</text>
|
||||
<text x="210" y="138" textLength="209">test</text>
|
||||
<text x="524" y="148" textLength="132" fill="#000" opacity="0.25">ok</text>
|
||||
<text x="514" y="138" textLength="132">ok</text>
|
||||
</g>
|
||||
<image x="40" y="35" width="130" height="130" xlink:href="data:image/svg+xml;base64,PHN2ZyBmaWxsPSIjRkZGIiByb2xlPSJpbWciIHZpZXdCb3g9IjAgMCAyNCAyNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNMjMuNTQ2IDEwLjkzTDEzLjA2Ny40NTJjLS42MDQtLjYwMy0xLjU4Mi0uNjAzLTIuMTg4IDBMOC43MDggMi42MjdsMi43NiAyLjc2Yy42NDUtLjIxNSAxLjM3OS0uMDcgMS44ODkuNDQxLjUxNi41MTUuNjU4IDEuMjU4LjQzOCAxLjlsMi42NTggMi42NmMuNjQ1LS4yMjMgMS4zODctLjA3OCAxLjkuNDM1LjcyMS43Mi43MjEgMS44ODQgMCAyLjYwNC0uNzE5LjcxOS0xLjg4MS43MTktMi42IDAtLjUzOS0uNTQxLS42NzQtMS4zMzctLjQwNC0xLjk5NkwxMi44NiA4Ljk1NXY2LjUyNWMuMTc2LjA4Ni4zNDIuMjAzLjQ4OC4zNDguNzEzLjcyMS43MTMgMS44ODMgMCAyLjYtLjcxOS43MjEtMS44ODkuNzIxLTIuNjA5IDAtLjcxOS0uNzE5LS43MTktMS44NzkgMC0yLjU5OC4xODItLjE4LjM4Ny0uMzE2LjYwNS0uNDA2VjguODM1Yy0uMjE3LS4wOTEtLjQyNC0uMjIyLS42LS40MDEtLjU0NS0uNTQ1LS42NzYtMS4zNDItLjM5Ni0yLjAwOUw3LjYzNiAzLjcuNDUgMTAuODgxYy0uNi42MDUtLjYgMS41ODQgMCAyLjE4OWwxMC40OCAxMC40NzdjLjYwNC42MDQgMS41ODIuNjA0IDIuMTg2IDBsMTAuNDMtMTAuNDNjLjYwNS0uNjAzLjYwNS0xLjU4MiAwLTIuMTg3Ii8+PC9zdmc+Cg=="/>
|
||||
</svg>
|
||||
`
|
56
test/index.spec.js
Normal file
56
test/index.spec.js
Normal file
@ -0,0 +1,56 @@
|
||||
const tap = require('tap')
|
||||
const execa = require('execa')
|
||||
|
||||
const check = async (t, params) => {
|
||||
const result = await execa('./cli.js', params)
|
||||
if (result.stderr) {
|
||||
t.fail()
|
||||
} else {
|
||||
t.matchSnapshot(result.stdout, t.name)
|
||||
}
|
||||
}
|
||||
|
||||
tap.test('No status', async t => {
|
||||
const error = await execa.stderr('./cli.js')
|
||||
t.ok(error.includes('status'))
|
||||
})
|
||||
|
||||
tap.test('Status only', async t => {
|
||||
await check(t, ['--status', 'ok'])
|
||||
t.end()
|
||||
})
|
||||
|
||||
tap.test('Subject and status', async t => {
|
||||
await check(t, ['--subject', 'test', '--status', 'ok'])
|
||||
t.end()
|
||||
})
|
||||
|
||||
tap.test('Status and color', async t => {
|
||||
await check(t, ['--status', 'ok', '--color', 'red'])
|
||||
t.end()
|
||||
})
|
||||
|
||||
tap.test('Status and flat', async t => {
|
||||
await check(t, ['--status', 'ok', '--flat'])
|
||||
t.end()
|
||||
})
|
||||
|
||||
tap.test('Assert icon from subject', async t => {
|
||||
await check(t, ['--subject', 'chrome', '--status', 'ok', '--icon'])
|
||||
t.end()
|
||||
})
|
||||
|
||||
tap.test('Status and icon', async t => {
|
||||
await check(t, ['--status', 'ok', '--icon', 'npm'])
|
||||
t.end()
|
||||
})
|
||||
|
||||
tap.test('Subject, status and icon', async t => {
|
||||
await check(t, ['--subject', 'test', '--status', 'ok', '--icon', 'git'])
|
||||
t.end()
|
||||
})
|
||||
|
||||
tap.test('Override properties', async t => {
|
||||
await check(t, ['--subject', 'test', '--status', 'fail', '--color', 'red', '--status', 'ok', '--color', 'green'])
|
||||
t.end()
|
||||
})
|
Loading…
x
Reference in New Issue
Block a user