tnobody / lerna-audit

Micro util to run npm audit in lerna monorepos
9 stars 11 forks source link

package.json: save file like npm would #19

Closed wiese closed 3 years ago

wiese commented 3 years ago

Minimize the diffs when saving package.json by leveraging the original npm method. It determines the pre-existing indentation and newline style used in the file and re-applies it to the updated content (with limitations, cf. 1).

An alternative would have been to look for solutions which operate comparable to the manipulation of binary files, exchanging only the differing bits, but this seems much more involved (i.e. risky) and possibly in vain if npm would - sooner or later - overwrite them anyway.

Resolves #15

wiese commented 3 years ago

When installing @npmcli/arborist (on npm 6.14.8) this bumped the package-lock.json to "lockfileVersion": 2 - I can try to undo this if that's an issue, but maybe let's first discuss if the core idea behind this PR is an option for you to begin with.

svettwer commented 3 years ago

related to #15

svettwer commented 3 years ago

Finally found some time to take a look. Looks good to me. :+1: Thx a lot for your contribution