Skip to content

Commit

Permalink
fix(install): add an option to track the original lockfile version
Browse files Browse the repository at this point in the history
  • Loading branch information
siemhesda committed Jan 8, 2024
1 parent 2999cc4 commit 4c8c602
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 1 addition & 2 deletions lib/commands/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const pacote = require('pacote')
const checks = require('npm-install-checks')

const ArboristWorkspaceCmd = require('../arborist-cmd.js')
const { defaultLockfileVersion } = require('@npmcli/arborist/lib/shrinkwrap.js')
class Install extends ArboristWorkspaceCmd {
static description = 'Install a package'
static name = 'install'
Expand Down Expand Up @@ -151,7 +150,7 @@ class Install extends ArboristWorkspaceCmd {
const arb = new Arborist(opts)
await arb.reify(opts)

if (arb.options.lockfileVersion && arb.options.lockfileVersion < defaultLockfileVersion) {
if (arb.originalLockfileVersionOld) {
await arb.reify(opts)
}

Expand Down
2 changes: 2 additions & 0 deletions workspaces/arborist/lib/arborist/build-ideal-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ module.exports = cls => class IdealTreeBuilder extends cls {
this.idealTree = idealTree
this.installLinks = installLinks
this.legacyPeerDeps = legacyPeerDeps
this.originalLockfileVersionOld = false

this[_usePackageLock] = packageLock
this[_global] = !!global
Expand Down Expand Up @@ -690,6 +691,7 @@ module.exports = cls => class IdealTreeBuilder extends cls {
const heading = ancient ? 'ancient lockfile' : 'old lockfile'
if (ancient || !this.options.lockfileVersion ||
this.options.lockfileVersion >= defaultLockfileVersion) {
this.originalLockfileVersionOld = true
log.warn(heading,
`
The ${meta.type} file was created with an old version of npm,
Expand Down

0 comments on commit 4c8c602

Please sign in to comment.