Skip to content

Commit 33ca01c

Browse files
jamiekyle-ebsindresorhus
authored andcommitted
Fix using the gitignore and stats options together (#121)
1 parent c737820 commit 33ca01c

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ const checkCwdOption = options => {
2222
}
2323
};
2424

25+
const getPathString = p => p instanceof fs.Stats ? p.path : p;
26+
2527
const generateGlobTasks = (patterns, taskOptions) => {
2628
patterns = arrayUnion([].concat(patterns));
2729
assertPatternsInput(patterns);
@@ -110,7 +112,7 @@ const globby = (patterns, options) => {
110112
return getTasks
111113
.then(tasks => Promise.all(tasks.map(task => fastGlob(task.pattern, task.options))))
112114
.then(paths => arrayUnion(...paths))
113-
.then(paths => paths.filter(p => !filter(p)));
115+
.then(paths => paths.filter(p => !filter(getPathString(p))));
114116
});
115117
};
116118

test.js

+6
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,12 @@ test('respects gitignore option false - sync', t => {
221221
t.true(actual.indexOf('node_modules') > -1);
222222
});
223223

224+
test('gitignore option with stats option', async t => {
225+
const res = await globby('*', {gitignore: true, stats: true});
226+
const actual = res.map(s => s.path);
227+
t.false(actual.indexOf('node_modules') > -1);
228+
});
229+
224230
// https://github.com/sindresorhus/globby/issues/97
225231
test.failing('`{extension: false}` and `expandDirectories.extensions` option', t => {
226232
t.deepEqual(

0 commit comments

Comments
 (0)