Skip to content

Commit

Permalink
chore: reuse globFiles utility
Browse files Browse the repository at this point in the history
  • Loading branch information
nikku committed Sep 20, 2023
1 parent b4d86f3 commit 98eec74
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions app/lib/util/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,29 +134,30 @@ function globFiles(pattern, options = {}) {

const {
searchPaths,
cwd,
...otherOptions
} = options;

if (searchPaths) {
return searchPaths.reduce((paths, searchPath) => {
return [
...paths,
...globSync(toPosixPath(pattern), {
...defaultOptions,
...globFiles(pattern, {
...otherOptions,
cwd: toPosixPath(searchPath)
}).map(toPosixPath)
cwd: searchPath
})
];
}, []);
}

if (otherOptions.cwd) {
otherOptions.cwd = toPosixPath(otherOptions.cwd);
}
const cwdOptions = cwd
? { cwd: toPosixPath(cwd) }
: {};

return globSync(toPosixPath(pattern), {
...defaultOptions,
...otherOptions
...otherOptions,
...cwdOptions
}).map(toPosixPath);
}

Expand Down

0 comments on commit 98eec74

Please sign in to comment.