Skip to content

Commit 7b77545

Browse files
authored
Merge pull request #35 from RyanRHall/master
Make getJsonFilePaths recursive
2 parents 3a4f9e2 + 612e2b3 commit 7b77545

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/artifact-paths.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@ import path from "path";
22
import fs from "fs";
33

44
export const getJsonFilePaths = (artifactPath: string): string[] => {
5-
const files = fs.readdirSync(artifactPath);
6-
const jsonFiles = files.filter(
7-
(filename) => filename.split(".").pop()?.toLowerCase() === "json",
8-
);
9-
const jsonPaths = jsonFiles.map((filename) =>
10-
path.join(artifactPath, filename),
11-
);
12-
return jsonPaths;
5+
let result: string[] = []
6+
const files = fs.readdirSync(artifactPath)
7+
files.forEach(file => {
8+
const childPath = path.join(artifactPath, file)
9+
if (fs.statSync(childPath).isDirectory()) {
10+
result.push(...getJsonFilePaths(childPath))
11+
} else if (path.extname(childPath) === ".json") {
12+
result.push(childPath)
13+
}
14+
})
15+
return result.sort()
1316
};

0 commit comments

Comments
 (0)