See discussion in #38, which was originally meant to address #37 but ended up in a slippery slope of scope creep.
Basically, we overwrite package.json using JSON.stringify(pkg, null, 2) + '\n' but this may be too intrusive for folks using Windows line endings (\r\n instead of \n) or different indentation (tabs instead of spaces, or more than 2 spaces).
Here are a couple ways we could address this:
detect-newline and detect-indent (similar to #38)require()ing it) and just replace the "version" value, ignoring/preserving all other content/formattingI think I'd prefer option 2.
I also think our CHANGELOG writing logic should not be affected by this.
Probably should be similar to how npm-version does it.
@nexdrew might be worth looking at how greenkeeper does it.
Looks like npm version pretty much does the same thing that standard-version does. Hmm, maybe this is a non-issue then...
Is this still an issue?
@stevemao I think we can close this. If anyone complains we can revisit.
@nexdrew I'm having problems with this, I use 4 spaces in the package.json, but it's changing to 2 spaces.
Could preserve the file, how you said.
tested in v4.3.0
I think we should reopen this since npm preserves the format now.
please preserve the code format, we are always fixing conflicts on package.json
Can I submit a pull request for this ? Which option do you prefer ?
Read package.json as string (instead of require()ing it) and just replace the "version" value, ignoring/preserving all other content/formatting
I am agree with this
I've been looking for this for a while, so just got around to creating a PR for this: #282
It's basically a mix of both suggestions and is the same solution npm uses to preserve the format.
@alasdairhurst @nexdrew is this still something anyone would like to take on?
@bcoe see the linked PR I provided - it's already merged by you and released in 5.0.0!
@bcoe this can be closed.
Most helpful comment
please preserve the code format, we are always fixing conflicts on package.json