diff --git a/gitignore.js b/gitignore.js index 3feaad6..6a1a57a 100644 --- a/gitignore.js +++ b/gitignore.js @@ -44,6 +44,7 @@ const reduceIgnore = files => { }; const ensureAbsolutePathForCwd = (cwd, p) => { + cwd = slash(cwd); if (path.isAbsolute(p)) { if (p.startsWith(cwd)) { return p; diff --git a/gitignore.test.js b/gitignore.test.js index eb02221..72ae0f2 100644 --- a/gitignore.test.js +++ b/gitignore.test.js @@ -1,5 +1,6 @@ import path from 'path'; import test from 'ava'; +import slash from 'slash'; import gitignore from './gitignore'; test('gitignore', async t => { @@ -10,6 +11,12 @@ test('gitignore', async t => { t.deepEqual(actual, expected); }); +test('gitignore - mixed path styles', async t => { + const cwd = path.join(__dirname, 'fixtures/gitignore'); + const isIgnored = await gitignore({cwd}); + t.true(isIgnored(slash(path.resolve(cwd, 'foo.js')))); +}); + test('gitignore - sync', t => { const cwd = path.join(__dirname, 'fixtures/gitignore'); const isIgnored = gitignore.sync({cwd});