Skip to content

Commit

Permalink
Fix expandDirectories.extension option (#263)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rick authored Feb 11, 2024
1 parent 3a28601 commit af5d139
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const getDirectoryGlob = ({directoryPath, files, extensions}) => {
const extensionGlob = extensions?.length > 0 ? `.${extensions.length > 1 ? `{${extensions.join(',')}}` : extensions[0]}` : '';
return files
? files.map(file => nodePath.posix.join(directoryPath, `**/${nodePath.extname(file) ? file : `${file}${extensionGlob}`}`))
: [nodePath.posix.join(directoryPath, `**${extensionGlob ? `/${extensionGlob}` : ''}`)];
: [nodePath.posix.join(directoryPath, `**${extensionGlob ? `/*${extensionGlob}` : ''}`)];
};

const directoryToGlob = async (directoryPaths, {
Expand Down
5 changes: 5 additions & 0 deletions tests/globby.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ test('expandDirectories option', async t => {
},
ignore: ['**/b.tmp'],
}), ['tmp/a.tmp']);
t.deepEqual(await runGlobby(t, temporary, {
expandDirectories: {
extensions: ['tmp'],
},
}), ['tmp/a.tmp', 'tmp/b.tmp', 'tmp/c.tmp', 'tmp/d.tmp', 'tmp/e.tmp']);
});

test('expandDirectories:true and onlyFiles:true option', async t => {
Expand Down

0 comments on commit af5d139

Please sign in to comment.