@@ -9,14 +9,14 @@ const stashAllFiles = async (): Promise<never | void> => {
|
9 | 9 | // stash files including untracked (eg. newly created file)
|
10 | 10 | const { stderr } = await exec({ command: `git stash --include-untracked` })
|
11 | 11 | if (stderr) {
|
12 |
| -console.error(stderr) |
| 12 | +logger(`Error: ${stderr}`) |
13 | 13 | throw new Error('Error stashing files')
|
14 | 14 | }
|
15 | 15 | }
|
16 | 16 |
|
17 | 17 | const cherryPickCommit = async (commit: string, count = 0): Promise<never | void> => {
|
18 | 18 | if (count > 1) {
|
19 |
| -console.warn('cherry-pick failed') |
| 19 | +logger('cherry-pick failed') |
20 | 20 | return
|
21 | 21 | }
|
22 | 22 | try {
|
@@ -26,8 +26,8 @@ const cherryPickCommit = async (commit: string, count = 0): Promise<never | void
|
26 | 26 | if (!stdout) {
|
27 | 27 | throw new Error('No cherry-pick output')
|
28 | 28 | }
|
29 |
| -} catch (error) { |
30 |
| -console.log('cherry-pick-commit failed') |
| 29 | +} catch (error: any) { |
| 30 | +logger(`cherry-pick-commit failed: ${error.message}`) |
31 | 31 | // stash all files if cherry-pick fails
|
32 | 32 | await stashAllFiles()
|
33 | 33 | return cherryPickCommit(commit, ++count)
|
@@ -50,10 +50,10 @@ export function loadCommit(commit: string): Promise<never | void> {
|
50 | 50 | export async function saveCommit(message: string): Promise<never | void> {
|
51 | 51 | const { stdout, stderr } = await exec({ command: `git commit -am '${message}'` })
|
52 | 52 | if (stderr) {
|
53 |
| -console.error(stderr) |
| 53 | +logger(`Error: ${stderr}`) |
54 | 54 | throw new Error('Error saving progress to Git')
|
55 | 55 | }
|
56 |
| -logger(['save with commit & continue stdout', stdout]) |
| 56 | +logger(`Commit saved: ${stdout}`) |
57 | 57 | }
|
58 | 58 |
|
59 | 59 | export async function clear(): Promise<Error | void> {
|
@@ -63,9 +63,9 @@ export async function clear(): Promise<Error | void> {
|
63 | 63 | if (!stderr) {
|
64 | 64 | return
|
65 | 65 | }
|
66 |
| -console.error(stderr) |
67 |
| -} catch (error) { |
68 |
| -console.error(error) |
| 66 | +logger(`Error: ${stderr}`) |
| 67 | +} catch (error: any) { |
| 68 | +logger(`Error: ${error.message}`) |
69 | 69 | }
|
70 | 70 | throw new Error('Error cleaning up current unsaved work')
|
71 | 71 | }
|
@@ -127,7 +127,7 @@ export async function addRemote(repo: string): Promise<never | void> {
|
127 | 127 |
|
128 | 128 | // validate the response is acceptable
|
129 | 129 | if (!alreadyExists && !successfulNewBranch) {
|
130 |
| -console.error(stderr) |
| 130 | +logger(`Error: ${stderr}`) |
131 | 131 | throw new Error('Error adding git remote')
|
132 | 132 | }
|
133 | 133 | }
|
@@ -142,7 +142,8 @@ export async function checkRemoteExists(): Promise<boolean> {
|
142 | 142 | // string match on remote output
|
143 | 143 | // TODO improve the specificity of this regex
|
144 | 144 | return !!stdout.match(gitOrigin)
|
145 |
| -} catch (error) { |
| 145 | +} catch (error: any) { |
| 146 | +logger(`Warn: ${error.message}`) |
146 | 147 | return false
|
147 | 148 | }
|
148 | 149 | }
|
@@ -168,8 +169,9 @@ export async function loadCommitHistory(): Promise<string[]> {
|
168 | 169 | }
|
169 | 170 | // string match on remote output
|
170 | 171 | return stdout.split('\n')
|
171 |
| -} catch (error) { |
| 172 | +} catch (error: any) { |
172 | 173 | // likely no git setup or no commits
|
| 174 | +logger(`Warn: ${error.message}`) |
173 | 175 | return []
|
174 | 176 | }
|
175 | 177 | }
|
@@ -189,8 +191,8 @@ export async function getCommitMessage(hash: string): Promise<string | null> {
|
189 | 191 | }
|
190 | 192 | // string match on remote output
|
191 | 193 | return stdout
|
192 |
| -} catch (error) { |
193 |
| -logger('error', error) |
| 194 | +} catch (error: any) { |
| 195 | +logger(`Error: ${error.message}`) |
194 | 196 | // likely no git commit message found
|
195 | 197 | return null
|
196 | 198 | }
|
@@ -204,8 +206,8 @@ export async function commitsExistsByMessage(message: string): Promise<boolean>
|
204 | 206 | return false
|
205 | 207 | }
|
206 | 208 | return !!stdout.length
|
207 |
| -} catch (error) { |
208 |
| -logger('error', error) |
| 209 | +} catch (error: any) { |
| 210 | +logger(`Error: ${error.message}`) |
209 | 211 | // likely no commit found
|
210 | 212 | return false
|
211 | 213 | }
|
|
0 commit comments