Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use concat instead of push around listFolders #1139

Merged
merged 2 commits into from
Jul 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/analyze-action.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/analyze-action.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 8 additions & 6 deletions src/analyze-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down