Skip to content

Commit 55eae66

Browse files
author
Chao Zhang
committed
Support find .sarif files recursively
1 parent 094554c commit 55eae66

3 files changed

Lines changed: 24 additions & 15 deletions

File tree

lib/upload-lib.js

Lines changed: 12 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/upload-lib.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/upload-lib.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,17 @@ export async function upload(
104104
throw new Error(`Path does not exist: ${sarifPath}`);
105105
}
106106
if (fs.lstatSync(sarifPath).isDirectory()) {
107-
const paths = fs
108-
.readdirSync(sarifPath)
109-
.filter((f) => f.endsWith(".sarif"))
110-
.map((f) => path.resolve(sarifPath, f));
111-
for (const filepath of paths) {
112-
sarifFiles.push(filepath);
113-
}
107+
const walkSarifFiles = (dir: string) => {
108+
const entries = fs.readdirSync(dir, { withFileTypes: true });
109+
for (const entry of entries) {
110+
if (entry.isFile() && entry.name.endsWith(".sarif")) {
111+
sarifFiles.push(path.resolve(dir, entry.name));
112+
} else if (entry.isDirectory()) {
113+
walkSarifFiles(path.resolve(dir, entry.name));
114+
}
115+
}
116+
};
117+
walkSarifFiles(sarifPath);
114118
if (sarifFiles.length === 0) {
115119
throw new Error(`No SARIF files found to upload in "${sarifPath}".`);
116120
}

0 commit comments

Comments
 (0)