mirror of
https://github.com/github/codeql-action.git
synced 2026-01-06 22:50:17 +08:00
Use concat instead of push around listFolders
This avoids stack overflows when using the spread operator on directories that have many, many children.
This commit is contained in:
@@ -151,17 +151,19 @@ async function run() {
|
||||
|
||||
if (config.debugMode) {
|
||||
// Upload the logs as an Actions artifact for debugging
|
||||
const toUpload: string[] = [];
|
||||
let toUpload: string[] = [];
|
||||
for (const language of config.languages) {
|
||||
toUpload.push(
|
||||
...listFolder(
|
||||
toUpload = toUpload.concat(
|
||||
listFolder(
|
||||
path.resolve(util.getCodeQLDatabasePath(config, language), "log")
|
||||
)
|
||||
);
|
||||
}
|
||||
if (await codeQlVersionAbove(codeql, CODEQL_VERSION_NEW_TRACING)) {
|
||||
// Multilanguage tracing: there are additional logs in the root of the cluster
|
||||
toUpload.push(...listFolder(path.resolve(config.dbLocation, "log")));
|
||||
toUpload = toUpload.concat(
|
||||
listFolder(path.resolve(config.dbLocation, "log"))
|
||||
);
|
||||
}
|
||||
await uploadDebugArtifacts(
|
||||
toUpload,
|
||||
@@ -319,12 +321,12 @@ async function uploadDebugArtifacts(
|
||||
|
||||
function listFolder(dir: string): string[] {
|
||||
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
||||
const files: string[] = [];
|
||||
let files: string[] = [];
|
||||
for (const entry of entries) {
|
||||
if (entry.isFile()) {
|
||||
files.push(path.resolve(dir, entry.name));
|
||||
} else if (entry.isDirectory()) {
|
||||
files.push(...listFolder(path.resolve(dir, entry.name)));
|
||||
files = files.concat(listFolder(path.resolve(dir, entry.name)));
|
||||
}
|
||||
}
|
||||
return files;
|
||||
|
||||
Reference in New Issue
Block a user