File tree 6 files changed +15
-14
lines changed
6 files changed +15
-14
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
+ const inquirer = require ( 'inquirer' ) ;
3
4
const { prompter} = require ( '@commitlint/prompt' ) ;
4
5
5
- const _ = undefined ;
6
- const prompt = ( ) => prompter ( _ , commit ) ;
7
-
8
6
main ( ) . catch ( ( err ) => {
9
7
setTimeout ( ( ) => {
10
8
throw err ;
@@ -21,7 +19,7 @@ function main() {
21
19
process . exit ( 1 ) ;
22
20
}
23
21
} )
24
- . then ( ( ) => prompt ( ) ) ;
22
+ . then ( ( ) => prompter ( inquirer , commit ) ) ;
25
23
}
26
24
27
25
function isStageEmpty ( ) {
Original file line number Diff line number Diff line change 36
36
},
37
37
"dependencies" : {
38
38
"@commitlint/prompt" : " ^11.0.0" ,
39
+ "inquirer" : " ^6.5.2" ,
39
40
"execa" : " ^5.0.0"
40
41
},
41
42
"gitHead" : " cb565dfcca3128380b9b3dc274aedbcae34ce5ca"
Original file line number Diff line number Diff line change
1
+ const inquirer = require ( "inquirer" ) ;
1
2
const { prompter} = require ( "../lib" ) ;
2
3
3
- process . stdin . isTTY = false ;
4
- process . stdout . isTTY = false ;
5
- prompter ( null , ( answers ) => {
4
+ prompter ( inquirer , ( answers ) => {
6
5
console . log ( '!$#$!' )
7
6
console . log ( answers )
8
7
console . log ( '!$#$!' )
Original file line number Diff line number Diff line change 40
40
"@types/inquirer" : " ^6.5.0" ,
41
41
"@types/concat-stream" : " ^1.6.0" ,
42
42
"commitizen" : " 4.2.2" ,
43
- "concat-stream" : " ^2.0.0"
43
+ "concat-stream" : " ^2.0.0" ,
44
+ "inquirer" : " ^6.5.2"
44
45
},
45
46
"dependencies" : {
46
47
"@commitlint/load" : " ^11.0.0" ,
47
48
"chalk" : " ^4.0.0" ,
48
- "inquirer" : " ^6.5.2" ,
49
49
"lodash" : " ^4.17.19"
50
50
},
51
51
"gitHead" : " cb565dfcca3128380b9b3dc274aedbcae34ce5ca"
Original file line number Diff line number Diff line change 1
1
import inquirer from 'inquirer' ;
2
2
import input from './input' ;
3
+ import InputCustomPrompt from './inquirer/InputCustomPrompt' ;
3
4
4
5
type Commit = ( input : string ) => void ;
5
6
6
7
/**
7
8
* Entry point for commitizen
8
- * @param _ inquirer instance passed by commitizen, unused
9
+ * @param cz inquirer instance passed by commitizen
9
10
* @param commit callback to execute with complete commit message
10
11
* @return generated commit message
11
12
*/
12
- export async function prompter ( _ : unknown , commit : Commit ) : Promise < void > {
13
- const message = await input ( inquirer . createPromptModule ( ) ) ;
13
+ export async function prompter (
14
+ cz : typeof inquirer ,
15
+ commit : Commit
16
+ ) : Promise < void > {
17
+ cz . prompt . registerPrompt ( 'input-custom' , InputCustomPrompt ) ;
18
+ const message = await input ( cz . prompt ) ;
14
19
commit ( message ) ;
15
20
}
Original file line number Diff line number Diff line change @@ -6,7 +6,6 @@ import getPrompt from './library/get-prompt';
6
6
import settings from './settings' ;
7
7
import { InputSetting , Result } from './library/types' ;
8
8
9
- import InputCustomPrompt from './inquirer/InputCustomPrompt' ;
10
9
import { getHasName , getMaxLength , getRules } from './library/utils' ;
11
10
12
11
/**
@@ -26,7 +25,6 @@ export default async function input(prompter: PromptModule): Promise<string> {
26
25
const maxLength = getMaxLength ( headerLengthRule ) ;
27
26
28
27
try {
29
- prompter . registerPrompt ( 'input-custom' , InputCustomPrompt ) ;
30
28
const questions : DistinctQuestion < Result > [ ] = [ ] ;
31
29
32
30
for ( const input of parts ) {
You can’t perform that action at this time.
0 commit comments