@@ -9,14 +9,14 @@ const stashAllFiles = async (): Promise<never | void> => {
99// stash files including untracked (eg. newly created file)
1010const { stderr} = await exec ( { command :`git stash --include-untracked` } )
1111if ( stderr ) {
12- console . error ( stderr )
12+ logger ( `Error: ${ stderr } ` )
1313throw new Error ( 'Error stashing files' )
1414}
1515}
1616
1717const cherryPickCommit = async ( commit :string , count = 0 ) :Promise < never | void > => {
1818if ( count > 1 ) {
19- console . warn ( 'cherry-pick failed' )
19+ logger ( 'cherry-pick failed' )
2020return
2121}
2222try {
@@ -26,8 +26,8 @@ const cherryPickCommit = async (commit: string, count = 0): Promise<never | void
2626if ( ! stdout ) {
2727throw 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
3232await stashAllFiles ( )
3333return cherryPickCommit ( commit , ++ count )
@@ -50,10 +50,10 @@ export function loadCommit(commit: string): Promise<never | void> {
5050export async function saveCommit ( message :string ) :Promise < never | void > {
5151const { stdout, stderr} = await exec ( { command :`git commit -am '${ message } '` } )
5252if ( stderr ) {
53- console . error ( stderr )
53+ logger ( `Error: ${ stderr } ` )
5454throw 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> {
6363if ( ! stderr ) {
6464return
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}
7070throw 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
129129if ( ! alreadyExists && ! successfulNewBranch ) {
130- console . error ( stderr )
130+ logger ( `Error: ${ stderr } ` )
131131throw 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
144144return ! ! stdout . match ( gitOrigin )
145- } catch ( error ) {
145+ } catch ( error :any ) {
146+ logger ( `Warn:${ error . message } ` )
146147return false
147148}
148149}
@@ -168,8 +169,9 @@ export async function loadCommitHistory(): Promise<string[]> {
168169}
169170// string match on remote output
170171return stdout . split ( '\n' )
171- } catch ( error ) {
172+ } catch ( error : any ) {
172173// likely no git setup or no commits
174+ logger ( `Warn:${ error . message } ` )
173175return [ ]
174176}
175177}
@@ -189,8 +191,8 @@ export async function getCommitMessage(hash: string): Promise<string | null> {
189191}
190192// string match on remote output
191193return stdout
192- } catch ( error ) {
193- logger ( 'error' , error )
194+ } catch ( error : any ) {
195+ logger ( `Error: ${ error . message } ` )
194196// likely no git commit message found
195197return null
196198}
@@ -204,8 +206,8 @@ export async function commitsExistsByMessage(message: string): Promise<boolean>
204206return false
205207}
206208return ! ! stdout . length
207- } catch ( error ) {
208- logger ( 'error' , error )
209+ } catch ( error : any ) {
210+ logger ( `Error: ${ error . message } ` )
209211// likely no commit found
210212return false
211213}