Skip to content

Commit

Permalink
lint: Avoid committing .npmrc changes (#1129)
Browse files Browse the repository at this point in the history
I thought that excluding the `added` state would be enough 🤦.
  • Loading branch information
72636c authored Mar 20, 2023
1 parent 08b0c03 commit b42399a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .changeset/chilled-spiders-drive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'skuba': patch
---

lint: Avoid committing `.npmrc` changes

`skuba lint` can automatically commit codegen changes if you have [GitHub autofixes](https://seek-oss.github.io/skuba/docs/deep-dives/github.html#github-autofixes) enabled on your project. Previously we made sure to exclude a new `.npmrc` file from the commit, but we now exclude changes to an existing `.npmrc` too.
15 changes: 15 additions & 0 deletions src/cli/lint/autofix.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,21 @@ describe('autofix', () => {
`);
});

it('skips an .npmrc modification only', async () => {
jest.spyOn(Git, 'getChangedFiles').mockResolvedValue([
{
path: '.npmrc',
state: 'modified',
},
]);

await expect(
autofix({ ...params, eslint: false, prettier: false }),
).resolves.toBeUndefined();

expectNoAutofix();
});

it('handles codegen changes only', async () => {
jest.spyOn(Git, 'getChangedFiles').mockResolvedValue([
{
Expand Down
6 changes: 6 additions & 0 deletions src/cli/lint/autofix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ export const AUTOFIX_IGNORE_FILES: Git.ChangedFile[] = [
path: '.npmrc',
state: 'added',
},
{
// This file may already exist in version control, but we shouldn't commit
// further changes as the CI environment may have appended an npm token.
path: '.npmrc',
state: 'modified',
},
{
path: 'Dockerfile-incunabulum',
state: 'added',
Expand Down

0 comments on commit b42399a

Please sign in to comment.