Skip to content

Commit

Permalink
Merge pull request #29 from veracode/fixEmptyResults
Browse files Browse the repository at this point in the history
Fix empty results
  • Loading branch information
julz0815 authored Mar 29, 2024
2 parents 3e357c7 + 6a75cda commit 6f565b4
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 10 deletions.
25 changes: 20 additions & 5 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38612,6 +38612,7 @@ function runAction(options) {
}));
}
else {
core.info('Command to run: ' + command);
const execution = (0, child_process_1.spawn)('sh', ['-c', command], {
stdio: "pipe",
shell: false
Expand All @@ -38630,14 +38631,28 @@ function runAction(options) {
var _b;
//core.info(output);
core.info(`Scan finished with exit code: ${code}`);
core.info(output);
//write output to file
(0, fs_1.writeFile)('scaResults.txt', output, (err) => {
if (err)
throw err;
// writeFile('scaResults.txt', output, (err) => {
// if (err) throw err;
// console.log('The file has been saved!');
// });
try {
(0, fs_1.writeFileSync)('scaResults.txt', output);
console.log('The file has been saved!');
});
}
catch (err) {
console.error('Error writing file:', err);
}
// core.info('reading file')
// try {
// const data = readFileSync('scaResults.txt', 'utf8');
// console.log('Full file output: '+data);
// } catch (err) {
// console.error(err);
// }
//store output files as artifacts
core.info('Store json Results as Artifact');
core.info('Store txt Results as Artifact');
const artifact = __nccwpck_require__(1413);
const artifactClient = artifact.create();
const artifactName = 'Veracode Agent Based SCA Results';
Expand Down
29 changes: 24 additions & 5 deletions src/srcclr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { SCA_OUTPUT_FILE,run, runText } from "./index";
import * as github from '@actions/github'
import { env } from "process";
import { writeFile } from 'fs';
import { readFileSync } from 'fs';
import { writeFileSync } from 'fs';


const cleanCollectors = (inputArr:Array<string>) => {
Expand Down Expand Up @@ -137,7 +139,7 @@ export async function runAction (options: Options) {


} else {

core.info('Command to run: '+command)
const execution = spawn('sh',['-c',command],{
stdio:"pipe",
shell:false
Expand All @@ -160,14 +162,31 @@ export async function runAction (options: Options) {
//core.info(output);
core.info(`Scan finished with exit code: ${code}`);

core.info(output)
//write output to file
writeFile('scaResults.txt', output, (err) => {
if (err) throw err;
// writeFile('scaResults.txt', output, (err) => {
// if (err) throw err;
// console.log('The file has been saved!');
// });

try {
writeFileSync('scaResults.txt', output);
console.log('The file has been saved!');
});
} catch (err) {
console.error('Error writing file:', err);
}


// core.info('reading file')
// try {
// const data = readFileSync('scaResults.txt', 'utf8');
// console.log('Full file output: '+data);
// } catch (err) {
// console.error(err);
// }

//store output files as artifacts
core.info('Store json Results as Artifact')
core.info('Store txt Results as Artifact')
const artifact = require('@actions/artifact');
const artifactClient = artifact.create()
const artifactName = 'Veracode Agent Based SCA Results';
Expand Down

0 comments on commit 6f565b4

Please sign in to comment.