Skip to content

Commit

Permalink
Fix using the gitignore and stats options together (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiekyle-eb authored and sindresorhus committed May 27, 2019
1 parent c737820 commit 33ca01c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const checkCwdOption = options => {
}
};

const getPathString = p => p instanceof fs.Stats ? p.path : p;

const generateGlobTasks = (patterns, taskOptions) => {
patterns = arrayUnion([].concat(patterns));
assertPatternsInput(patterns);
Expand Down Expand Up @@ -110,7 +112,7 @@ const globby = (patterns, options) => {
return getTasks
.then(tasks => Promise.all(tasks.map(task => fastGlob(task.pattern, task.options))))
.then(paths => arrayUnion(...paths))
.then(paths => paths.filter(p => !filter(p)));
.then(paths => paths.filter(p => !filter(getPathString(p))));
});
};

Expand Down
6 changes: 6 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,12 @@ test('respects gitignore option false - sync', t => {
t.true(actual.indexOf('node_modules') > -1);
});

test('gitignore option with stats option', async t => {
const res = await globby('*', {gitignore: true, stats: true});
const actual = res.map(s => s.path);
t.false(actual.indexOf('node_modules') > -1);
});

// https://github.com/sindresorhus/globby/issues/97
test.failing('`{extension: false}` and `expandDirectories.extensions` option', t => {
t.deepEqual(
Expand Down

0 comments on commit 33ca01c

Please sign in to comment.