question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Preserve formatting of package.json

See original GitHub issue

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:

  1. Detect and preserve newline chars and indentation via detect-newline and detect-indent (similar to #38)
  2. Read package.json as string (instead of require()ing it) and just replace the "version" value, ignoring/preserving all other content/formatting

I think I’d prefer option 2.

I also think our CHANGELOG writing logic should not be affected by this.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:4
  • Comments:13 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
hugomrdiascommented, Feb 28, 2018

please preserve the code format, we are always fixing conflicts on package.json

3reactions
nexdrewcommented, Jun 8, 2016

Looks like npm version pretty much does the same thing that standard-version does. Hmm, maybe this is a non-issue then…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Stop re-formatting package.json with Prettier and VSCode ...
You are using VSCode, Prettier and have configured auto formatting on save. Now you, go to package. json or tsconfig. json, you change ......
Read more >
Coping strategy for npm --save reformatting package.json
To make sure your package.json is automatically reformatted and not relying on the developer to do it, you can add reformatting as part...
Read more >
package.json - npm Docs
json are the name and version fields as they will be required. The name and version together form an identifier that is assumed...
Read more >
Can I make npm install follow a certain package.json format?
Is there any way to make npm follow the existing format, or to specifiy a custom format (e.g. 4-space indentation) for the package.json...
Read more >
Respect package.json formatting · Issue #5694 - GitHub
Indentation is now detected and preserved for package.json , package-lock.json , and npm-shrinkwrap.json . If the package lock is missing, it ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found