From 357934fe1e193040d1a138d3d138da1377004be2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iiro=20J=C3=A4ppinen?= Date: Sat, 17 Aug 2019 10:47:08 +0300 Subject: [PATCH] fix: try applying unstaged changes before handling errors --- src/runAll.js | 10 ++++++---- test/__snapshots__/runAll.spec.js.snap | 2 ++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/runAll.js b/src/runAll.js index e6adedcff..580e11928 100644 --- a/src/runAll.js +++ b/src/runAll.js @@ -114,6 +114,11 @@ 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, @@ -121,10 +126,7 @@ https://github.com/okonet/lint-staged#using-js-functions-to-customize-linter-com }, { title: 'Cleaning up...', - task: async ctx => { - if (!ctx.hasErrors) await git.restoreUnstagedChanges() - await git.dropBackup() - } + task: () => git.dropBackup() } ], listrOptions diff --git a/test/__snapshots__/runAll.spec.js.snap b/test/__snapshots__/runAll.spec.js.snap index 040bcaa6d..ccd4b18d7 100644 --- a/test/__snapshots__/runAll.spec.js.snap +++ b/test/__snapshots__/runAll.spec.js.snap @@ -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]" `;