Skip to content

Commit f9fc476

Browse files
authored
Fix gitignore option compatibility with objectMode option (#157)
1 parent 7807d29 commit f9fc476

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

gitignore.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const ensureAbsolutePathForCwd = (cwd, p) => {
5959
};
6060

6161
const getIsIgnoredPredecate = (ignores, cwd) => {
62-
return p => ignores.ignores(slash(path.relative(cwd, ensureAbsolutePathForCwd(cwd, p))));
62+
return p => ignores.ignores(slash(path.relative(cwd, ensureAbsolutePathForCwd(cwd, p.path || p))));
6363
};
6464

6565
const getFile = async (file, cwd) => {

test.js

+12
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,18 @@ test('respects gitignore option false - stream', async t => {
303303
t.true(actual.includes('node_modules'));
304304
});
305305

306+
test('gitingore option and objectMode option - async', async t => {
307+
const result = await globby('fixtures/gitignore/*', {gitignore: true, objectMode: true});
308+
t.is(result.length, 1);
309+
t.truthy(result[0].path);
310+
});
311+
312+
test('gitingore option and objectMode option - sync', t => {
313+
const result = globby.sync('fixtures/gitignore/*', {gitignore: true, objectMode: true});
314+
t.is(result.length, 1);
315+
t.truthy(result[0].path);
316+
});
317+
306318
test('`{extension: false}` and `expandDirectories.extensions` option', t => {
307319
t.deepEqual(
308320
globby.sync('*', {

0 commit comments

Comments
 (0)