diff --git a/src/common/common.ts b/src/common/common.ts index 14c1c4e..ebb97bb 100644 --- a/src/common/common.ts +++ b/src/common/common.ts @@ -36,9 +36,7 @@ export function getPidFilePath(): string { } export function getOutputDir(): string { - return WORKSPACE - ? path.join(WORKSPACE, RESULTS_DIR_NAME) - : path.join(__dirname, "..", "..", RESULTS_DIR_NAME); + return WORKSPACE || process.cwd(); } export function mockCoreForLocalTesting(): void { diff --git a/src/main/index.ts b/src/main/index.ts index 09b8aa8..6ba12ed 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -169,8 +169,6 @@ async function runKnoxctlScan(): Promise { const scanCommand: string[] = ["knoxctl", "scan"]; const outputDir = path.join(getOutputDir(), "knoxctl-results"); - scanCommand.push("--output", outputDir); - for (const option of knoxctlOptions) { let value: boolean | string; diff --git a/src/post/index.ts b/src/post/index.ts index 9709a1d..34fc6aa 100644 --- a/src/post/index.ts +++ b/src/post/index.ts @@ -211,11 +211,19 @@ async function run(): Promise { // Increase wait time and add file system sync await new Promise((resolve) => setTimeout(resolve, 15000)); - fs.readdirSync(getOutputDir()); // Force a file system sync + + const outputDir = getOutputDir(); + log(`Output directory: ${outputDir}`); + log("Contents of output directory:"); + const files = fs.readdirSync(outputDir); + for (const file of files) { + if (file.startsWith("knoxctl_scan_")) { + log(`- ${file}`); + } + } await processResults(); - const outputDir = getOutputDir(); await uploadArtifacts(outputDir); if (IS_GITHUB_ACTIONS) { @@ -241,6 +249,7 @@ async function uploadArtifacts(outputDir: string): Promise { const artifactName = "knoxctl-scan-results"; const files = fs .readdirSync(outputDir) + .filter((file) => file.startsWith("knoxctl_scan_")) .map((file) => path.join(outputDir, file)); log(`Uploading ${files.length} files as artifacts`);