Skip to content

Commit 6dd0af8

Browse files
authored
fix(scripts): do not destructure function parameter (#2891)
1 parent 57dbe3b commit 6dd0af8

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

scripts/downlevel-dts/getAllFiles.mjs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1+
// @ts-check
12
import { readdir, stat } from "fs/promises";
3+
import { join } from "path";
24

35
export const getAllFiles = async (dirPath, arrayOfFiles = []) => {
46
const files = await readdir(dirPath);
57

68
for (const file of files) {
7-
const { isDirectory } = await stat(dirPath + "/" + file);
8-
if (isDirectory()) {
9-
const filesInDirectory = await getAllFiles(dirPath + "/" + file, arrayOfFiles);
10-
arrayOfFiles.push(filesInDirectory);
9+
const filePath = join(dirPath, file);
10+
const stats = await stat(filePath);
11+
if (stats.isDirectory()) {
12+
const filesInDirectory = await getAllFiles(filePath, arrayOfFiles);
13+
arrayOfFiles.concat(filesInDirectory);
1114
} else {
12-
arrayOfFiles.push(join(dirPath, "/", file));
15+
arrayOfFiles.push(filePath);
1316
}
1417
}
1518

0 commit comments

Comments
 (0)