Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion workspaces/arborist/lib/arborist/reify.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ module.exports = cls => class Reifier extends cls {
this.actualTree = this.idealTree
this.idealTree = null

if (!this.options.global) {
if (!this.options.global && !this.options.dryRun) {
await this.actualTree.meta.save()
const ignoreScripts = !!this.options.ignoreScripts
// if we aren't doing a dry run or ignoring scripts and we actually made changes to the dep
Expand Down
20 changes: 20 additions & 0 deletions workspaces/arborist/test/arborist/reify.js
Original file line number Diff line number Diff line change
Expand Up @@ -1707,6 +1707,26 @@ t.test('save complete lockfile on update-all', async t => {
t.matchSnapshot(lock(), 'should update, but not drop root metadata')
})

t.test('dry-run update does not save lockfiles', async t => {
const path = t.testdir({
'package.json': JSON.stringify({
name: 'dry-run-update-lockfile-test',
version: '1.0.0',
}),
})
createRegistry(t, true)
await reify(path, { add: ['abbrev@1.0.4'] })

const lock = filename => fs.readFileSync(resolve(path, filename), 'utf8')
const packageLock = lock('package-lock.json')
const hiddenLock = lock('node_modules/.package-lock.json')

await reify(path, { update: true, dryRun: true, save: false })

t.equal(lock('package-lock.json'), packageLock, 'package-lock.json unchanged')
t.equal(lock('node_modules/.package-lock.json'), hiddenLock, 'hidden lockfile unchanged')
})

t.test('save proper lockfile with bins when upgrading lockfile', async t => {
for (const complete of [true, false]) {
await t.test(`complete=${complete}`, async t => {
Expand Down
Loading