Skip to content

Commit 917670c

Browse files
authored
Fix an edge-case bug (#242)
1 parent 4795466 commit 917670c

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

ignore.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const getIsIgnoredPredicate = (files, cwd) => {
5252
return fileOrDirectory => {
5353
fileOrDirectory = toPath(fileOrDirectory);
5454
fileOrDirectory = toRelativePath(fileOrDirectory, cwd);
55-
return ignores.ignores(slash(fileOrDirectory));
55+
return fileOrDirectory ? ignores.ignores(slash(fileOrDirectory)) : false;
5656
};
5757
};
5858

tests/globby.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,19 @@ test('expandDirectories and ignores option', async t => {
190190
}), ['tmp/a.tmp', 'tmp/b.tmp', 'tmp/c.tmp', 'tmp/d.tmp', 'tmp/e.tmp']);
191191
});
192192

193+
test('absolute:true, expandDirectories:false, onlyFiles:false, gitignore:true and top level folder', async t => {
194+
const result = await runGlobby(t, '.', {
195+
absolute: true,
196+
cwd: path.resolve(temporary),
197+
expandDirectories: false,
198+
gitignore: true,
199+
onlyFiles: false,
200+
});
201+
202+
t.is(result.length, 1);
203+
t.truthy(result[0].endsWith(temporary));
204+
});
205+
193206
test.serial.failing('relative paths and ignores option', async t => {
194207
process.chdir(temporary);
195208
for (const cwd of getPathValues(process.cwd())) {

0 commit comments

Comments
 (0)