Skip to content

Commit

Permalink
Merge pull request #4173 from snyk/fix/snyk-iac-test-error-handling
Browse files Browse the repository at this point in the history
fix: Errors from snyk-iac-test should not be swallowed
  • Loading branch information
francescomari authored Oct 26, 2022
2 parents af07068 + b02372d commit a120139
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/lib/iac/test/v2/scan/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,12 @@ async function scanWithConfig(
throw new ScanError(`spawning process: ${child.error}`);
}

return mapSnykIacTestOutputToTestOutput(await readJson(outputPath));
}

async function readJson(path: string) {
try {
const output = await readFile(outputPath);
return mapSnykIacTestOutputToTestOutput(JSON.parse(output));
return JSON.parse(await readFile(path));
} catch (e) {
throw new ScanError(`invalid output encoding: ${e}`);
}
Expand Down

0 comments on commit a120139

Please sign in to comment.