Skip to content

Commit

Permalink
fix: try applying unstaged changes before handling errors
Browse files Browse the repository at this point in the history
  • Loading branch information
iiroj authored and Andrey Okonetchnikov committed Oct 31, 2019
1 parent 31e440e commit 080f1c6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/runAll.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,19 @@ https://github.com/okonet/lint-staged#using-js-functions-to-customize-linter-com
title: 'Running tasks...',
task: () => new Listr(tasks, { ...listrOptions, concurrent: true, exitOnError: false })
},
{
title: 'Applying unstaged changes...',
skip: ctx => ctx.hasErrors && 'Skipped because of errors from tasks',
task: () => git.restoreUnstagedChanges()
},
{
title: 'Restoring original state due to errors...',
enabled: ctx => ctx.hasErrors,
task: () => git.restoreOriginalState()
},
{
title: 'Cleaning up...',
task: async ctx => {
if (!ctx.hasErrors) await git.restoreUnstagedChanges()
await git.dropBackup()
}
task: () => git.dropBackup()
}
],
listrOptions
Expand Down
2 changes: 2 additions & 0 deletions test/__snapshots__/runAll.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ LOG echo \\"sample\\" [started]
LOG echo \\"sample\\" [completed]
LOG Running tasks for *.js [completed]
LOG Running tasks... [completed]
LOG Applying unstaged changes... [started]
LOG Applying unstaged changes... [completed]
LOG Cleaning up... [started]
LOG Cleaning up... [completed]"
`;

0 comments on commit 080f1c6

Please sign in to comment.