Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalize file paths to posix for gitignore calculation #143

Merged
merged 1 commit into from
Jun 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions gitignore.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const reduceIgnore = files => {
};

const ensureAbsolutePathForCwd = (cwd, p) => {
cwd = slash(cwd);
if (path.isAbsolute(p)) {
if (p.startsWith(cwd)) {
return p;
Expand Down
7 changes: 7 additions & 0 deletions gitignore.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import path from 'path';
import test from 'ava';
import slash from 'slash';
import gitignore from './gitignore';

test('gitignore', async t => {
Expand All @@ -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});
Expand Down