Skip to content

Commit

Permalink
Do not swallow already detected deprecated usage by last task
Browse files Browse the repository at this point in the history
  • Loading branch information
bobisjan committed Jul 13, 2021
1 parent 4f9a146 commit aba6501
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/runAll.js
Expand Up @@ -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}`,
Expand Down
8 changes: 7 additions & 1 deletion test/integration.test.js
Expand Up @@ -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(`
Expand All @@ -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...
Expand Down

0 comments on commit aba6501

Please sign in to comment.