fix: --dry-run with --json output#8567
Conversation
This broke in 10.4 npm@c209e98#r165769221
|
Yeah we'll definitely want a regression test for this in |
|
you assigned this to yourself. does that mean you're planning to fix it? Or, should I put up a PR with tests? also, so you have any thoughts/comments on moving the "showfix" stuff outside the loop and have it print from the |
This is a signal to the rest of the team that I'm reviewing the PR. |
I think this is a good iteration and it should be a separate PR. This quick fix for parsing opts should be easier to land since it's just one missing conditional and a test, leaving the optimization for a different PR. |
## Summary - stop Arborist from saving `node_modules/.package-lock.json` during dry-run reification - add a regression that keeps both `package-lock.json` and the hidden lockfile unchanged after `update: true, dryRun: true` This addresses the dry-run lockfile mutation part of #9187. The JSON output behavior is separate and already has #8567 open. ## Testing - `../../node_modules/.bin/tap --no-coverage --no-check-coverage test/arborist/reify.js -g 'dry-run update does not save lockfiles'` - `../../node_modules/.bin/tap --no-coverage --no-check-coverage test/arborist/reify.js -g 'dry run, do not get anything wet|save complete lockfile on update-all'` - `../../node_modules/.bin/eslint lib/arborist/reify.js test/arborist/reify.js` - `git diff --check` Co-authored-by: Puneet Dixit <236133619+puneetdixit200@users.noreply.github.com>
This broke in 10.4. Before 10.4
npm install --dry-run --jsonwould return JSON. After 10.4 it no longer returns JSON.c209e98#r165769221
Note: This is the smallest change and I didn't update any tests. Nor was I sure where to one. The fact that it broke means there was no test for this before.
If it was up to me I think I'd add a
summary.diff = []and push the diffs on there. And then only at the end where it outputssummary, if you want diff output to stdout then map oversummary.diff. That would put the checks for output in a single place.References
Fixeds #8565