Skip to content

Commit b0239d2

Browse files
committed
feat(prompt-cli): add standalone prompt interface
1 parent 80501e8 commit b0239d2

File tree

3 files changed

+80
-0
lines changed

3 files changed

+80
-0
lines changed

@commitlint/prompt-cli/cli.js

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env node
2+
const execa = require('execa');
3+
const meow = require('meow');
4+
const prompter = require('@commitlint/prompt').prompter;
5+
6+
const HELP = `
7+
Usage
8+
$ commit
9+
`;
10+
11+
const _ = undefined;
12+
const prompt = () => prompter(_, commit);
13+
14+
main(meow(HELP))
15+
.catch(err => {
16+
setTimeout(() => {
17+
throw err;
18+
});
19+
});
20+
21+
function main() {
22+
return prompt();
23+
}
24+
25+
function commit(message) {
26+
const c = execa('git', ['commit', '-m', message]);
27+
c.stdout.pipe(process.stdout);
28+
c.stderr.pipe(process.stderr);
29+
}

@commitlint/prompt-cli/package.json

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "@commitlint/prompt",
3+
"version": "3.0.0",
4+
"description": "commit prompt using .commitlintrc",
5+
"bin": {
6+
"commit": "./cli.js"
7+
},
8+
"scripts": {
9+
"clean": "rimraf lib",
10+
"commit": "$npm_package_bin_commit",
11+
"pretest": "dep-check"
12+
},
13+
"xo": false,
14+
"repository": {
15+
"type": "git",
16+
"url": "git+https://github.com/marionebl/commitlint.git"
17+
},
18+
"keywords": [
19+
"commitlint",
20+
"prompt"
21+
],
22+
"author": "Mario Nebl <[email protected]>",
23+
"license": "MIT",
24+
"bugs": {
25+
"url": "https://github.com/marionebl/commitlint/issues"
26+
},
27+
"homepage": "https://github.com/marionebl/commitlint#readme",
28+
"devDependencies": {
29+
"@commitlint/utils": "^3.0.0"
30+
},
31+
"dependencies": {
32+
"@commitlint/prompt": "^3.0.0",
33+
"execa": "^0.7.0",
34+
"meow": "^3.7.0"
35+
}
36+
}

@commitlint/prompt-cli/readme.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
> commit prompt using .commitlintrc
2+
3+
# @commitlint/prompt-cli
4+
5+
## Getting started
6+
7+
```bash
8+
npm install --g @commitlint/prompt-cli @commitlint/config-angular
9+
echo '{"extends": ["@commitlint/config-angular"]}' > .commitlintrc
10+
```
11+
12+
```bash
13+
git add .
14+
commit
15+
```

0 commit comments

Comments
 (0)