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..dbc60edc5 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,11 +769,15 @@ 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] git add LOG [SUCCESS] Running tasks for *.js + LOG [SUCCESS] prettier --write + LOG [SUCCESS] Running tasks for **/*.js LOG [SUCCESS] Running tasks... LOG [STARTED] Applying modifications... ERROR [FAILED] Prevented an empty git commit!