Skip to content

Commit f2bdce6

Browse files
authored
Normalize file paths to posix for gitignore calculation (#143)
Refs #133
1 parent 45ac58a commit f2bdce6

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

gitignore.js

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const reduceIgnore = files => {
4444
};
4545

4646
const ensureAbsolutePathForCwd = (cwd, p) => {
47+
cwd = slash(cwd);
4748
if (path.isAbsolute(p)) {
4849
if (p.startsWith(cwd)) {
4950
return p;

gitignore.test.js

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import path from 'path';
22
import test from 'ava';
3+
import slash from 'slash';
34
import gitignore from './gitignore';
45

56
test('gitignore', async t => {
@@ -10,6 +11,12 @@ test('gitignore', async t => {
1011
t.deepEqual(actual, expected);
1112
});
1213

14+
test('gitignore - mixed path styles', async t => {
15+
const cwd = path.join(__dirname, 'fixtures/gitignore');
16+
const isIgnored = await gitignore({cwd});
17+
t.true(isIgnored(slash(path.resolve(cwd, 'foo.js'))));
18+
});
19+
1320
test('gitignore - sync', t => {
1421
const cwd = path.join(__dirname, 'fixtures/gitignore');
1522
const isIgnored = gitignore.sync({cwd});

0 commit comments

Comments
 (0)