Skip to content

Commit

Permalink
refactor: avoid calling stat manually on each entry (#2568)
Browse files Browse the repository at this point in the history
  • Loading branch information
barak007 authored Jun 14, 2023
1 parent c5c836b commit 52af4f0
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions packages/node/src/find-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@ export function findFiles(
while (folders.length) {
const current = folders.pop()!;
try {
fs.readdirSync(current).forEach((item: string) => {
if (blacklist.has(item)) {
fs.readdirSync(current, { withFileTypes: true }).forEach((item) => {
if (blacklist.has(item.name)) {
return;
}
const itemFullPath = join(current, item);
const itemFullPath = join(current, item.name);
try {
const status = fs.statSync(itemFullPath);
if (status.isDirectory()) {
if (item.isDirectory()) {
folders.push(itemFullPath);
} else if (status.isFile() && itemFullPath.endsWith(ext)) {
} else if (item.isFile() && itemFullPath.endsWith(ext)) {
result.add(
useRelative ? relative(rootDirectory, itemFullPath) : itemFullPath
);
Expand Down

0 comments on commit 52af4f0

Please sign in to comment.