@@ -72,11 +72,25 @@ const generateEnquirer = async (): Promise<
72
72
} ;
73
73
} ;
74
74
75
- export const gitCommit = async ( content : string ) => {
75
+ export const gitCommit = async (
76
+ type : string ,
77
+ scope : string ,
78
+ description : string ,
79
+ ) => {
76
80
if ( ACTIVATION ) {
77
- loggerInfo ( `gitCommit 参数信息: \n${ JSON . stringify ( content ) } ` ) ;
81
+ loggerInfo (
82
+ `gitCommit 参数信息: \n${ JSON . stringify ( {
83
+ type,
84
+ scope,
85
+ description,
86
+ } ) } `,
87
+ ) ;
78
88
}
79
- await execCommand ( "git" , [ "commit" , "-m" , content ] , { stdio : "inherit" } ) ;
89
+ await execCommand (
90
+ "git" ,
91
+ [ "commit" , "-m" , `${ type } (${ scope } ): ${ description } ` ] ,
92
+ { stdio : "inherit" } ,
93
+ ) ;
80
94
} ;
81
95
82
96
export default function gitCommitInstaller ( cli : CAC ) {
@@ -90,14 +104,12 @@ export default function gitCommitInstaller(cli: CAC) {
90
104
. option ( "-d, --description <description>" , "填写修改描述" )
91
105
. action ( async ( options ) => {
92
106
const { type, scope, description } = options ;
93
- let content = "" ;
94
107
if ( ! type || ! scope || ! description ) {
95
108
const result = await generateEnquirer ( ) ;
96
- content = ` ${ result . type } ( ${ result . scope } ): ${ result . description } ` ;
109
+ await gitCommit ( result . type , result . scope , result . description ) ;
97
110
} else {
98
- content = ` ${ type } ( ${ scope } ): ${ description } ` ;
111
+ await gitCommit ( type , scope , description ) ;
99
112
}
100
- await gitCommit ( content ) ;
101
113
} ) ;
102
114
} ,
103
115
} ;
0 commit comments