File tree 1 file changed +14
-2
lines changed
1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change 1
1
#!/usr/bin/env node
2
2
const execa = require ( 'execa' ) ;
3
3
const meow = require ( 'meow' ) ;
4
- const prompter = require ( '@commitlint/prompt' ) . prompter ;
4
+ const { prompter} = require ( '@commitlint/prompt' ) ;
5
5
6
6
const HELP = `
7
7
Usage
@@ -17,10 +17,22 @@ main(meow(HELP)).catch(err => {
17
17
} ) ;
18
18
} ) ;
19
19
20
- function main ( ) {
20
+ async function main ( ) {
21
+ if ( await isStageEmpty ( ) ) {
22
+ console . log (
23
+ `Nothing to commit. Stage your changes via "git add" execute "commit" again`
24
+ ) ;
25
+ process . exit ( 1 ) ;
26
+ }
27
+
21
28
return prompt ( ) ;
22
29
}
23
30
31
+ async function isStageEmpty ( ) {
32
+ const result = await execa ( 'git' , [ 'diff' , '--cached' ] ) ;
33
+ return result . stdout === '' ;
34
+ }
35
+
24
36
function commit ( message ) {
25
37
const c = execa ( 'git' , [ 'commit' , '-m' , message ] ) ;
26
38
c . stdout . pipe ( process . stdout ) ;
You can’t perform that action at this time.
0 commit comments