Skip to content

Commit 357934f

Browse files
committedNov 14, 2019
fix: try applying unstaged changes before handling errors
1 parent 061946c commit 357934f

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed
 

‎src/runAll.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -114,17 +114,19 @@ https://github.com/okonet/lint-staged#using-js-functions-to-customize-linter-com
114114
title: 'Running tasks...',
115115
task: () => new Listr(tasks, { ...listrOptions, concurrent: true, exitOnError: false })
116116
},
117+
{
118+
title: 'Applying unstaged changes...',
119+
skip: ctx => ctx.hasErrors && 'Skipped because of errors from tasks',
120+
task: () => git.restoreUnstagedChanges()
121+
},
117122
{
118123
title: 'Restoring original state due to errors...',
119124
enabled: ctx => ctx.hasErrors,
120125
task: () => git.restoreOriginalState()
121126
},
122127
{
123128
title: 'Cleaning up...',
124-
task: async ctx => {
125-
if (!ctx.hasErrors) await git.restoreUnstagedChanges()
126-
await git.dropBackup()
127-
}
129+
task: () => git.dropBackup()
128130
}
129131
],
130132
listrOptions

‎test/__snapshots__/runAll.spec.js.snap

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ LOG echo \\"sample\\" [started]
2323
LOG echo \\"sample\\" [completed]
2424
LOG Running tasks for *.js [completed]
2525
LOG Running tasks... [completed]
26+
LOG Applying unstaged changes... [started]
27+
LOG Applying unstaged changes... [completed]
2628
LOG Cleaning up... [started]
2729
LOG Cleaning up... [completed]"
2830
`;

0 commit comments

Comments
 (0)
Please sign in to comment.