Skip to content

Commit 6f565b4

Browse files
authored
Merge pull request #29 from veracode/fixEmptyResults
Fix empty results
2 parents 3e357c7 + 6a75cda commit 6f565b4

File tree

2 files changed

+44
-10
lines changed

2 files changed

+44
-10
lines changed

dist/index.js

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38612,6 +38612,7 @@ function runAction(options) {
3861238612
}));
3861338613
}
3861438614
else {
38615+
core.info('Command to run: ' + command);
3861538616
const execution = (0, child_process_1.spawn)('sh', ['-c', command], {
3861638617
stdio: "pipe",
3861738618
shell: false
@@ -38630,14 +38631,28 @@ function runAction(options) {
3863038631
var _b;
3863138632
//core.info(output);
3863238633
core.info(`Scan finished with exit code: ${code}`);
38634+
core.info(output);
3863338635
//write output to file
38634-
(0, fs_1.writeFile)('scaResults.txt', output, (err) => {
38635-
if (err)
38636-
throw err;
38636+
// writeFile('scaResults.txt', output, (err) => {
38637+
// if (err) throw err;
38638+
// console.log('The file has been saved!');
38639+
// });
38640+
try {
38641+
(0, fs_1.writeFileSync)('scaResults.txt', output);
3863738642
console.log('The file has been saved!');
38638-
});
38643+
}
38644+
catch (err) {
38645+
console.error('Error writing file:', err);
38646+
}
38647+
// core.info('reading file')
38648+
// try {
38649+
// const data = readFileSync('scaResults.txt', 'utf8');
38650+
// console.log('Full file output: '+data);
38651+
// } catch (err) {
38652+
// console.error(err);
38653+
// }
3863938654
//store output files as artifacts
38640-
core.info('Store json Results as Artifact');
38655+
core.info('Store txt Results as Artifact');
3864138656
const artifact = __nccwpck_require__(1413);
3864238657
const artifactClient = artifact.create();
3864338658
const artifactName = 'Veracode Agent Based SCA Results';

src/srcclr.ts

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { SCA_OUTPUT_FILE,run, runText } from "./index";
77
import * as github from '@actions/github'
88
import { env } from "process";
99
import { writeFile } from 'fs';
10+
import { readFileSync } from 'fs';
11+
import { writeFileSync } from 'fs';
1012

1113

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

138140

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

165+
core.info(output)
163166
//write output to file
164-
writeFile('scaResults.txt', output, (err) => {
165-
if (err) throw err;
167+
// writeFile('scaResults.txt', output, (err) => {
168+
// if (err) throw err;
169+
// console.log('The file has been saved!');
170+
// });
171+
172+
try {
173+
writeFileSync('scaResults.txt', output);
166174
console.log('The file has been saved!');
167-
});
175+
} catch (err) {
176+
console.error('Error writing file:', err);
177+
}
178+
179+
180+
// core.info('reading file')
181+
// try {
182+
// const data = readFileSync('scaResults.txt', 'utf8');
183+
// console.log('Full file output: '+data);
184+
// } catch (err) {
185+
// console.error(err);
186+
// }
168187

169188
//store output files as artifacts
170-
core.info('Store json Results as Artifact')
189+
core.info('Store txt Results as Artifact')
171190
const artifact = require('@actions/artifact');
172191
const artifactClient = artifact.create()
173192
const artifactName = 'Veracode Agent Based SCA Results';

0 commit comments

Comments
 (0)