From aba65016b71d99cac74f5d268f48b301effb4875 Mon Sep 17 00:00:00 2001 From: Jan Bobisud Date: Mon, 12 Jul 2021 15:11:07 +0200 Subject: [PATCH] Do not swallow already detected deprecated usage by last task --- lib/runAll.js | 3 ++- test/integration.test.js | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/runAll.js b/lib/runAll.js index 7ad7c56ed..ba76bdf13 100644 --- a/lib/runAll.js +++ b/lib/runAll.js @@ -147,7 +147,8 @@ const runAll = async ( matchedFiles.add(file) }) - hasDeprecatedGitAdd = subTasks.some((subTask) => subTask.command === 'git add') + hasDeprecatedGitAdd = + hasDeprecatedGitAdd || subTasks.some((subTask) => subTask.command === 'git add') chunkListrTasks.push({ title: `Running tasks for ${task.pattern}`, diff --git a/test/integration.test.js b/test/integration.test.js index 6be62a918..ad0e1ac33 100644 --- a/test/integration.test.js +++ b/test/integration.test.js @@ -756,7 +756,9 @@ describe('lint-staged', () => { // Since prettier reverts all changes, the commit should fail // use the old syntax with manual `git add` to provide a warning message await expect( - gitCommit({ config: { '*.js': ['prettier --write', 'git add'] } }) + gitCommit({ + config: { '*.js': ['prettier --write', 'git add'], '**/*.js': ['prettier --write'] }, + }) ).rejects.toThrowErrorMatchingInlineSnapshot(`"lint-staged failed"`) expect(console.printHistory()).toMatchInlineSnapshot(` @@ -767,9 +769,13 @@ describe('lint-staged', () => { LOG [SUCCESS] Preparing... LOG [STARTED] Running tasks... LOG [STARTED] Running tasks for *.js + LOG [STARTED] Running tasks for **/*.js + LOG [STARTED] prettier --write LOG [STARTED] prettier --write LOG [SUCCESS] prettier --write LOG [STARTED] git add + LOG [SUCCESS] prettier --write + LOG [SUCCESS] Running tasks for **/*.js LOG [SUCCESS] git add LOG [SUCCESS] Running tasks for *.js LOG [SUCCESS] Running tasks...