Skip to content

Commit

Permalink
Fix an edge-case bug (#242)
Browse files Browse the repository at this point in the history
  • Loading branch information
voxpelli committed Dec 12, 2022
1 parent 4795466 commit 917670c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ignore.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const getIsIgnoredPredicate = (files, cwd) => {
return fileOrDirectory => {
fileOrDirectory = toPath(fileOrDirectory);
fileOrDirectory = toRelativePath(fileOrDirectory, cwd);
return ignores.ignores(slash(fileOrDirectory));
return fileOrDirectory ? ignores.ignores(slash(fileOrDirectory)) : false;
};
};

Expand Down
13 changes: 13 additions & 0 deletions tests/globby.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,19 @@ test('expandDirectories and ignores option', async t => {
}), ['tmp/a.tmp', 'tmp/b.tmp', 'tmp/c.tmp', 'tmp/d.tmp', 'tmp/e.tmp']);
});

test('absolute:true, expandDirectories:false, onlyFiles:false, gitignore:true and top level folder', async t => {
const result = await runGlobby(t, '.', {
absolute: true,
cwd: path.resolve(temporary),
expandDirectories: false,
gitignore: true,
onlyFiles: false,
});

t.is(result.length, 1);
t.truthy(result[0].endsWith(temporary));
});

test.serial.failing('relative paths and ignores option', async t => {
process.chdir(temporary);
for (const cwd of getPathValues(process.cwd())) {
Expand Down

0 comments on commit 917670c

Please sign in to comment.