Skip to content

Commit 1d98a7b

Browse files
authored
Add test running commands to CLI (#8)
1 parent b730ad6 commit 1d98a7b

2 files changed

Lines changed: 32 additions & 10 deletions

File tree

README.md

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,13 @@ Shared developer tools for [π-Base packages](https://github.com/pi-base?q=&type
1616

1717
```bash
1818
$ npm install --save-dev @pi-base/dev
19+
$ npm set-script prepare "pi-base-dev prepare"
20+
$ npm run prepare
1921
```
2022

21-
`pi-base-dev` does not entirely encapsulate `husky`. You will probably also want to
22-
23-
```bash
24-
$ npm set-script prepare "husky install" && npm run prepare
25-
```
26-
27-
See [`husky`'s documentation](https://typicode.github.io/husky/#/) for more details.
28-
2923
## Configuration
3024

31-
`@pi-base/dev` exports a number of common config files
25+
`@pi-base/dev` exports a number of common base configurations
3226

3327
```javascript
3428
// .eslintrc.js

src/cli.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,47 @@ cli
2626
})
2727

2828
cli
29-
.command('lint-staged')
29+
.command('lint:staged')
3030
.description('Run linter on staged files')
3131
.action(() => {
3232
npx('lint-staged')
3333
})
3434

35+
cli
36+
.command('lint:prepare')
37+
.description('Install lint hooks')
38+
.action(() => {
39+
npx('husky', 'install')
40+
})
41+
3542
cli
3643
.command('lint:check')
3744
.description('Run linter')
3845
.action(() => {
3946
npx('eslint', 'src/**/*.ts', '*.js')
4047
})
4148

49+
cli
50+
.command('test')
51+
.description('Run tests')
52+
.action(() => {
53+
npx('jest')
54+
})
55+
56+
cli
57+
.command('test:cov')
58+
.description('Run tests with coverage')
59+
.action(() => {
60+
npx('jest', '--coverage')
61+
})
62+
63+
cli
64+
.command('test:cov')
65+
.description('Run tests in watch mode')
66+
.action(() => {
67+
npx('jest', '--watchAll')
68+
})
69+
4270
cli.parse(process.argv)
4371

4472
function npx(cmd: string, ...args: string[]) {

0 commit comments

Comments
 (0)