Skip to content

Commit 69aec7b

Browse files
committed
fix: remove redundant sanitize
1 parent 40ccd6c commit 69aec7b

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

src/modules/helpers/list-files.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,11 @@ const getAllFilesInner = async (
3333
dirPath: string,
3434
files: Set<string>,
3535
filter: RegExp,
36-
exclude: RegExp[] | undefined
36+
exclude: RegExp[] | undefined,
37+
knownDirectory?: boolean
3738
): Promise<Set<string>> => {
3839
try {
39-
const stat = await fsStat(dirPath);
40-
41-
if (stat.isFile()) {
40+
if (!knownDirectory && (await fsStat(dirPath)).isFile()) {
4241
const fullPath = sanitizePath(dirPath);
4342

4443
if (
@@ -60,7 +59,7 @@ const getAllFilesInner = async (
6059
return files;
6160
}
6261

63-
const entries = await readdir(sanitizePath(dirPath), {
62+
const entries = await readdir(dirPath, {
6463
withFileTypes: true,
6564
});
6665
const subdirs: Promise<Set<string>>[] = [];
@@ -75,7 +74,7 @@ const getAllFilesInner = async (
7574
if (entry.isFile()) {
7675
if (filter.test(fullPath)) files.add(fullPath);
7776
} else if (entry.isDirectory()) {
78-
subdirs.push(getAllFilesInner(fullPath, files, filter, exclude));
77+
subdirs.push(getAllFilesInner(fullPath, files, filter, exclude, true));
7978
}
8079
}
8180

0 commit comments

Comments
 (0)