Add --json-file-output=<file>
option to directly save JSON output to file
#1059
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This allows a user to directly save JSON format output to a file as specified by the
--json-file-output=<file>
parameter, regardless of whether they are using the human-readable or json output. The primary use-case of this is to enable users (and Snyk CI plugins) to simultaneously get the human readable output while saving a JSON format output to a file for other purposes (for example, generating a report).Where should the reviewer start?
Please take a look at the code and advise as to testing best-practices. I will then include appropriate tests for this PR.
How should this be manually tested?
Say you want to save the JSON output to a file called "snyk-output.json" in the current directory. You could then run
snyk test --json-file-output=snyk-output.json
which should do a normal snyk test and generate the human-readable output to stdout but at the same time save the JSON format output tosnyk-output.json
.Any background context you want to provide?
We need this for https://github.com/snyk/snyk/issues/1027 and https://github.com/snyk/snyk-azure-pipelines-task/issues/30 as well as for another CI plugin we're currently working on.
What are the relevant tickets?
Screenshots
Additional questions