GeezerVison is showing github.com — fix: print backup stash example when failing to `--fail-on-changes` · lint-staged/lint-staged@47d01a9
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: lib/index.js +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -156,7 +156,8 @@ const lintStaged = async ( |
156 | 156 | } else if (ctx.errors.has(ApplyEmptyCommitError)) { |
157 | 157 | logger.warn(PREVENTED_EMPTY_COMMIT) |
158 | 158 | } else if (ctx.errors.has(FailOnChangesError)) { |
159 | | - logger.warn(PREVENTED_TASK_MODIFICATIONS) |
| 159 | + logger.warn(PREVENTED_TASK_MODIFICATIONS + '\n') |
| 160 | + logger.warn(RESTORE_STASH_EXAMPLE) |
160 | 161 | } else if (ctx.errors.has(RestoreUnstagedChangesError)) { |
161 | 162 | logger.warn(UNSTAGED_CHANGES_BACKUP_STASH_LOCATION) |
162 | 163 | logger.warn(ctx.unstagedPatch) |
|
Collapse file
Copy file name to clipboardExpand all lines: test/integration/fail-on-changes.test.js +9-5Lines changed: 9 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -14,15 +14,19 @@ describe('lint-staged', () => { |
14 | 14 | await writeFile('test.js', fileFixtures.uglyJS) |
15 | 15 | await execGit(['add', 'test.js']) |
16 | 16 |
|
17 | | - // Run lint-staged with `prettier --write` so that it modifies files |
18 | | - await expect(() => |
19 | | - gitCommit({ |
| 17 | + expect.assertions(3) |
| 18 | + |
| 19 | + try { |
| 20 | + // Run lint-staged with `prettier --write` so that it modifies files |
| 21 | + await gitCommit({ |
20 | 22 | lintStaged: { |
21 | 23 | failOnChanges: true, |
22 | | - quiet: true, |
23 | 24 | }, |
24 | 25 | }) |
25 | | - ).rejects.toThrow('lint-staged failed because `--fail-on-changes` was used') |
| 26 | + } catch (error) { |
| 27 | + expect(error.message).toMatch('lint-staged failed because `--fail-on-changes` was used') |
| 28 | + expect(error.message).toMatch('"skip":"Cleaning up temporary files..."') |
| 29 | + } |
26 | 30 |
|
27 | 31 | // Changes weren't reverted because "--no-revert" is implied |
28 | 32 | expect(await readFile('test.js')).toEqual(fileFixtures.prettyJS) |
|