Skip to content

Commit

Permalink
Merge pull request #100 from snyk/fix/use-sync-write-output
Browse files Browse the repository at this point in the history
Use sync write output
  • Loading branch information
maxjeffos authored Mar 3, 2021
2 parents bc64fcc + 47d29a2 commit da933ee
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ SnykToHtml.run(

function onReportOutput(report: string): void {
if (output) {
fs.writeFile(output, report, (err) => {
if (err) {
return console.log(err);
}
try {
fs.writeFileSync(output, report);
console.log('Vulnerability snapshot saved at ' + output);
});
} catch (err) {
return console.log(err);
}
} else {
console.log(report);
}
Expand Down
9 changes: 6 additions & 3 deletions tap-snapshots/test-snyk-to-html.test.ts-TAP.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4048,18 +4048,21 @@ exports[`test/snyk-to-html.test.ts TAP template output displays vulns in descend
<p>If for some reason upgrading is not an option, consider the following workarounds:</p>
<ol>
<li><p>Disable handling XML pages and requests to such pages</p>
<pre><code class="language-xml">&lt;constant name=&quot;struts.action.extension&quot; value=&quot;xhtml,,json&quot; /&gt;</code></pre>
<pre><code class="language-xml">&lt;constant name=&quot;struts.action.extension&quot; value=&quot;xhtml,,json&quot; /&gt;
</code></pre>
</li>
<li><p>Override getContentType in XStreamHandler</p>
<pre><code class="language-java">public class MyXStreamHandler extends XStreamHandler {
public String getContentType() {
return &quot;not-existing-content-type-@;/&amp;%$#@&quot;;
}
}</code></pre>
}
</code></pre>
</li>
<li><p>Register the handler by overriding the one provided by the framework in your struts.xml</p>
<pre><code class="language-xml">&lt;bean type=&quot;org.apache.struts2.rest.handler.ContentTypeHandler&quot; name=&quot;myXStreamHandmer&quot; class=&quot;com.company.MyXStreamHandler&quot;/&gt;
&lt;constant name=&quot;struts.rest.handlerOverride.xml&quot; value=&quot;myXStreamHandler&quot;/&gt;</code></pre>
&lt;constant name=&quot;struts.rest.handlerOverride.xml&quot; value=&quot;myXStreamHandler&quot;/&gt;
</code></pre>
</li>
</ol>
<h2 id="references">References</h2>
Expand Down

0 comments on commit da933ee

Please sign in to comment.