@@ -9,14 +9,14 @@ const stashAllFiles = async (): Promise<never | void> => {
99 // stash files including untracked (eg. newly created file)
1010 const { stderr } = await exec ( { command : `git stash --include-untracked` } )
1111 if ( stderr ) {
12- console . error ( stderr )
12+ logger ( `Error: ${ stderr } ` )
1313 throw new Error ( 'Error stashing files' )
1414 }
1515}
1616
1717const cherryPickCommit = async ( commit : string , count = 0 ) : Promise < never | void > => {
1818 if ( count > 1 ) {
19- console . warn ( 'cherry-pick failed' )
19+ logger ( 'cherry-pick failed' )
2020 return
2121 }
2222 try {
@@ -26,8 +26,8 @@ const cherryPickCommit = async (commit: string, count = 0): Promise<never | void
2626 if ( ! stdout ) {
2727 throw new Error ( 'No cherry-pick output' )
2828 }
29- } catch ( error ) {
30- console . log ( ' cherry-pick-commit failed' )
29+ } catch ( error : any ) {
30+ logger ( ` cherry-pick-commit failed: ${ error . message } ` )
3131 // stash all files if cherry-pick fails
3232 await stashAllFiles ( )
3333 return cherryPickCommit ( commit , ++ count )
@@ -50,10 +50,10 @@ export function loadCommit(commit: string): Promise<never | void> {
5050export async function saveCommit ( message : string ) : Promise < never | void > {
5151 const { stdout, stderr } = await exec ( { command : `git commit -am '${ message } '` } )
5252 if ( stderr ) {
53- console . error ( stderr )
53+ logger ( `Error: ${ stderr } ` )
5454 throw new Error ( 'Error saving progress to Git' )
5555 }
56- logger ( [ 'save with commit & continue stdout' , stdout ] )
56+ logger ( `Commit saved: ${ stdout } ` )
5757}
5858
5959export async function clear ( ) : Promise < Error | void > {
@@ -63,9 +63,9 @@ export async function clear(): Promise<Error | void> {
6363 if ( ! stderr ) {
6464 return
6565 }
66- console . error ( stderr )
67- } catch ( error ) {
68- console . error ( error )
66+ logger ( `Error: ${ stderr } ` )
67+ } catch ( error : any ) {
68+ logger ( `Error: ${ error . message } ` )
6969 }
7070 throw new Error ( 'Error cleaning up current unsaved work' )
7171}
@@ -127,7 +127,7 @@ export async function addRemote(repo: string): Promise<never | void> {
127127
128128 // validate the response is acceptable
129129 if ( ! alreadyExists && ! successfulNewBranch ) {
130- console . error ( stderr )
130+ logger ( `Error: ${ stderr } ` )
131131 throw new Error ( 'Error adding git remote' )
132132 }
133133 }
@@ -142,7 +142,8 @@ export async function checkRemoteExists(): Promise<boolean> {
142142 // string match on remote output
143143 // TODO improve the specificity of this regex
144144 return ! ! stdout . match ( gitOrigin )
145- } catch ( error ) {
145+ } catch ( error : any ) {
146+ logger ( `Warn: ${ error . message } ` )
146147 return false
147148 }
148149}
@@ -168,8 +169,9 @@ export async function loadCommitHistory(): Promise<string[]> {
168169 }
169170 // string match on remote output
170171 return stdout . split ( '\n' )
171- } catch ( error ) {
172+ } catch ( error : any ) {
172173 // likely no git setup or no commits
174+ logger ( `Warn: ${ error . message } ` )
173175 return [ ]
174176 }
175177}
@@ -189,8 +191,8 @@ export async function getCommitMessage(hash: string): Promise<string | null> {
189191 }
190192 // string match on remote output
191193 return stdout
192- } catch ( error ) {
193- logger ( 'error' , error )
194+ } catch ( error : any ) {
195+ logger ( `Error: ${ error . message } ` )
194196 // likely no git commit message found
195197 return null
196198 }
@@ -204,8 +206,8 @@ export async function commitsExistsByMessage(message: string): Promise<boolean>
204206 return false
205207 }
206208 return ! ! stdout . length
207- } catch ( error ) {
208- logger ( 'error' , error )
209+ } catch ( error : any ) {
210+ logger ( `Error: ${ error . message } ` )
209211 // likely no commit found
210212 return false
211213 }
0 commit comments