From f67edfe92f6efd6f2c8dd974318a90b1c16dcb2c Mon Sep 17 00:00:00 2001 From: barak igal Date: Mon, 22 Mar 2021 11:52:54 +0200 Subject: [PATCH] Fix Windows compatibility for gitignore option (#171) --- gitignore.js | 2 +- gitignore.test.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/gitignore.js b/gitignore.js index 95227a1..2f77baa 100644 --- a/gitignore.js +++ b/gitignore.js @@ -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; } diff --git a/gitignore.test.js b/gitignore.test.js index fcc1fa4..fd25b31 100644 --- a/gitignore.test.js +++ b/gitignore.test.js @@ -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});