File tree Expand file tree Collapse file tree 6 files changed +1774
-73
lines changed
Expand file tree Collapse file tree 6 files changed +1774
-73
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import prompts from 'prompts'
88import { program } from 'commander'
99import fs from 'fs'
1010import os from 'os'
11+ import { sanitizeCommitMessage } from './utils/sanitizeCommitMessage.js'
1112
1213let openai
1314let model = 'gpt-4o' // Default model
@@ -101,20 +102,19 @@ const gptCommit = async () => {
101102 }
102103
103104 const response = await openai . chat . completions . create ( parameters )
104- console . log ( response . choices [ 0 ] . message . content )
105- const message = response . choices [ 0 ] . message . content
106- . replace ( / [ ^ \w \s . : @ < > / - ] / gi, '' )
107- . trim ( )
105+
106+ const message = response . choices [ 0 ] . message . content . trim ( )
107+ const sanitizedMessage = sanitizeCommitMessage ( message )
108108
109109 const confirm = await prompts ( {
110110 type : 'confirm' ,
111111 name : 'value' ,
112- message : `${ message } .` ,
112+ message : `${ sanitizedMessage } .` ,
113113 initial : true ,
114114 } )
115115
116116 if ( confirm . value ) {
117- execSync ( `git commit -m "${ message } "` ) // escape double quart
117+ execSync ( `git commit -m "${ sanitizedMessage } "` ) // escape double quart
118118 console . log ( 'Committed with the suggested message.' )
119119 } else {
120120 console . log ( 'Commit canceled.' )
Original file line number Diff line number Diff line change 66 "type" : " module" ,
77 "scripts" : {
88 "prepare" : " husky" ,
9- "prettier" : " prettier --ignore-unknown --write ."
9+ "prettier" : " prettier --ignore-unknown --write ." ,
10+ "test" : " vitest"
1011 },
1112 "repository" : {
1213 "type" : " git" ,
3536 "node" : " 22.15.0"
3637 },
3738 "devDependencies" : {
39+ "@vitest/coverage-v8" : " 3.1.2" ,
40+ "@vitest/ui" : " ^3.1.2" ,
3841 "husky" : " ^9.1.7" ,
42+ "jsdom" : " ^26.1.0" ,
3943 "lint-staged" : " ^15.5.1" ,
40- "prettier" : " ^3.5.3"
44+ "prettier" : " ^3.5.3" ,
45+ "vite" : " ^6.3.3" ,
46+ "vitest" : " ^3.1.2"
4147 },
4248 "lint-staged" : {
4349 "*" : " prettier --ignore-unknown --write"
You can’t perform that action at this time.
0 commit comments