Open taneliang opened 6 years ago
Was just told of https://github.com/ljharb/json-file-plus, which is less accurate but should be faster.
However, upon some investigation, it seems like npm and yarn accept if the same package is included as 2 types of dependencies (npm gives a warning, and yarn only warns if the packages have colliding ranges). As such, a regex that upgrades every occurrence of the package should suffice.
Cotton currently generates updated package.json files using
JSON.stringify
, indented with 2 spaces and with a newline at the bottom. However, repos may have package.json files formatted differently. Cotton will thus mess them up, resulting in ugly first PR diffs and a poor user experience.Cotton should ideally update the content of the package.json files without affecting the existing formatting. I have thought of some approaches: