Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

fix: set lockfileVersion from file during reset #340

Closed
wants to merge 1 commit into from

Conversation

lukekarrys
Copy link
Member

Fix: npm/cli#3920

When loading the initial tree while updating all, a shrinkwrap file
loaded from disk with an existing lockfileVersion was not having the
lockfileVersion preserved when saving the file back to disk.

With this patch, an existing lockfileVersion is preserved if it is
greater than the defaultLockfileVersion.

const loadAndReset = (options) => Promise.all([
Shrinkwrap.load(options).then((s) => s.lockfileVersion),
Shrinkwrap.reset(options).then((s) => s.lockfileVersion),
])
Copy link
Member Author

Choose a reason for hiding this comment

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

I thought it was worthwhile to reuse the existing tests for Shrinkwrap.load to ensure that all calls to Shrinkwrap.reset work as expected.

Currently there are some calls to Shrinkwrap.reset that leave lockfileVersion as null when the existing shrinkwrap lockfileVersion is less than or equal to the default version. I'm not sure if it's worth changing so that reset always sets lockfileVersion to 1 || 2 || 3 when reading from disk.

@lukekarrys lukekarrys force-pushed the lk/update-downgrade-lockfile branch 2 times, most recently from 95d850a to 5aaf60c Compare October 21, 2021 21:52
Fix: npm/cli#3920

When loading the initial tree while updating all, a shrinkwrap file
loaded from disk with an existing `lockfileVersion` was not having the
`lockfileVersion` preserved when saving the file back to disk.

With this patch, an existing `lockfileVersion` is preserved if it is
greater than the `defaultLockfileVersion`.

Co-authored-by: @isaacs
@isaacs isaacs closed this in 38cee94 Oct 27, 2021
@lukekarrys lukekarrys deleted the lk/update-downgrade-lockfile branch October 27, 2021 16:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] npm update downgrades lockfile version
1 participant