Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implemented ability to save JSON report to file #400

Closed
wants to merge 1 commit into from
Closed

implemented ability to save JSON report to file #400

wants to merge 1 commit into from

Conversation

fumblehool
Copy link

@fumblehool fumblehool commented Mar 16, 2021

Fixes: #257

--json flag will save json report to file.
Example $ npm-check --json=/home/user/report.json will save JSON report to /home/user/report.json

Sample report:

[
    {
        "moduleName": "babel-runtime",
        "homepage": "https://github.com/babel/babel",
        "latest": "6.26.0",
        "installed": "6.26.0",
        "isInstalled": true,
        "notInstalled": false,
        "packageWanted": "6.26.0",
        "packageJson": "^6.6.1",
        "devDependency": false,
        "mismatch": false,
        "semverValid": "6.26.0",
        "easyUpgrade": true,
        "bump": null,
        "unused": false
    }
]

@sebastianrothe
Copy link

Can this be merged, please ?

@Ephigenia
Copy link

It is pretty common to support JSON format in a CLI tool. Usually this is done with the --json option and allows additional processing to the output and also storing, or even appending to files using POSIX pipe. I’d think if this PR is changed so that it only prints out the JSON it's totally fine.

npx npm-check --json > my-report.json

And even processing would be easier, just imagine using jq for filtering and processing:

npx npm-check --json | jq '.[] | {name: .modulename}'

With just printing the JSON it would become more flexible. If you’re interested there’s a pretty good chapter about output here: https://clig.dev/#output

Copy link

@Ephigenia Ephigenia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommended change here to output JSON instead of writing to a file.

@fumblehool
Copy link
Author

fumblehool commented Apr 30, 2023

closing this PR in-favour of PR: #532 cc @Ephigenia 😄

@fumblehool fumblehool closed this Apr 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to save report to file
3 participants