Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix: try applying unstaged changes before handling errors
  • Loading branch information
iiroj committed Nov 14, 2019
1 parent 061946c commit 357934f
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
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
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 357934f

Please sign in to comment.