Skip to content

Commit

Permalink
Fix Windows compatibility for gitignore option (#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
barak007 committed Mar 22, 2021
1 parent 20bb8ae commit f67edfe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gitignore.js
Expand Up @@ -48,7 +48,7 @@ const reduceIgnore = files => {
const ensureAbsolutePathForCwd = (cwd, p) => {
cwd = slash(cwd);
if (path.isAbsolute(p)) {
if (p.startsWith(cwd)) {
if (slash(p).startsWith(cwd)) {
return p;
}

Expand Down
6 changes: 6 additions & 0 deletions gitignore.test.js
Expand Up @@ -17,6 +17,12 @@ test('gitignore - mixed path styles', async t => {
t.true(isIgnored(slash(path.resolve(cwd, 'foo.js'))));
});

test('gitignore - os paths', async t => {
const cwd = path.join(__dirname, 'fixtures/gitignore');
const isIgnored = await gitignore({cwd});
t.true(isIgnored(path.resolve(cwd, 'foo.js')));
});

test('gitignore - sync', t => {
const cwd = path.join(__dirname, 'fixtures/gitignore');
const isIgnored = gitignore.sync({cwd});
Expand Down

0 comments on commit f67edfe

Please sign in to comment.