Skip to content

Commit

Permalink
fix: don't emit package-lock.json when package.json does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
xiongmao86 committed Dec 23, 2023
1 parent 86ac76c commit 1481863
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions workspaces/arborist/lib/arborist/reify.js
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,10 @@ module.exports = cls => class Reifier extends cls {
}
}

const isObjectEmpty = (obj) => {
return Object.keys(obj).length === 0 && obj.constructor === Object
}

// before now edge specs could be changing, affecting the `requires` field
// in the package lock, so we hold off saving to the very last action
if (this[_usePackageLock]) {
Expand All @@ -1457,10 +1461,12 @@ module.exports = cls => class Reifier extends cls {
}

// TODO this ignores options.save
await this.idealTree.meta.save({
format: (this[_formatPackageLock] && format) ? format
: this[_formatPackageLock],
})
if (!isObjectEmpty(this.idealTree.package)) {
await this.idealTree.meta.save({
format: (this[_formatPackageLock] && format) ? format
: this[_formatPackageLock],
})
}
}

process.emit('timeEnd', 'reify:save')
Expand Down

0 comments on commit 1481863

Please sign in to comment.