Skip to content

Commit

Permalink
Trim ignore file content and do not ignore pattern start with ./
Browse files Browse the repository at this point in the history
  • Loading branch information
zanminkian committed May 14, 2024
1 parent b0d7330 commit 407f6e0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion fixtures/gitignore/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
foo.js
!bar.js
!bar.js
./baz.js
3 changes: 2 additions & 1 deletion ignore.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ const parseIgnoreFile = (file, cwd) => {

return file.content
.split(/\r?\n/)
.filter(line => line && !line.startsWith('#'))
.map(line => line.trimEnd())
.filter(line => line && !line.startsWith('#') && !line.startsWith('./') && !line.startsWith('../'))
.map(pattern => applyBaseToPattern(pattern, base));
};

Expand Down
4 changes: 2 additions & 2 deletions tests/ignore.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ test('ignore', async t => {
const actual = await runIsGitIgnored(
t,
{cwd},
isIgnored => ['foo.js', 'bar.js'].filter(file => !isIgnored(file)),
isIgnored => ['foo.js', 'bar.js', 'baz.js'].filter(file => !isIgnored(file)),
);
const expected = ['bar.js'];
const expected = ['bar.js', 'baz.js'];
t.deepEqual(actual, expected);
}
});
Expand Down

0 comments on commit 407f6e0

Please sign in to comment.