Skip to content

Commit

Permalink
Force posix formatted paths for parsed ignore patterns (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
marionebl authored and sindresorhus committed Apr 18, 2017
1 parent 9e68450 commit 3021494
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions options-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,13 @@ const getGitIgnores = opts => globby
})
.map(pathToGitignore => {
const patterns = parseGitignore(pathToGitignore);
const base = path.dirname(pathToGitignore);
const base = path.posix.dirname(pathToGitignore);

return patterns
.map(pattern => {
const negate = !pattern.startsWith('!');
const patternPath = negate ? pattern : pattern.substr(1);
return {negate, pattern: path.join(base, patternPath)};
return {negate, pattern: path.posix.join(base, patternPath)};
})
.sort(pattern => pattern.negate ? 1 : -1)
.map(item => item.negate ? `!${item.pattern}` : item.pattern);
Expand Down
8 changes: 4 additions & 4 deletions test/options-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ test('groupConfigs', t => {

test('gitignore', t => {
const ignores = manager.getGitIgnores({});
t.not(ignores.indexOf('!' + path.join('foo', '**')), -1);
t.not(ignores.indexOf('!' + path.join('bar', 'foo.js')), -1);
t.not(ignores.indexOf(path.join('bar', 'bar.js')), -1);
t.not(ignores.indexOf('!foo/**'), -1);
t.not(ignores.indexOf('!bar/foo.js'), -1);
t.not(ignores.indexOf('bar/bar.js'), -1);
});

test('ignore ignored .gitignore', t => {
Expand All @@ -187,7 +187,7 @@ test('ignore ignored .gitignore', t => {
};

const ignores = manager.getGitIgnores(opts);
t.is(ignores.indexOf('!' + path.join('bar', 'foobar', 'bar.js')), -1);
t.is(ignores.indexOf('!bar/foobar/bar.js'), -1);
});

test('mergeWithPkgConf: use child if closest', t => {
Expand Down

0 comments on commit 3021494

Please sign in to comment.