-
-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preserving indentation in package-lock.json #22
Comments
Am I right that I like to have keep format, but I do not want to spend time to writing it. So please send PR. |
We recently changed the indentation in our project, and I noticed that |
One way to work around this, is to run the |
I think Prettier would be overkill for this use case. A full Prettier installion through npm is 3.9 MB. While Prettier is good at folding related code onto one line so it's easier to read, it could conflict with automatic formats from other tools, and package locks often don't need to be read by humans. I think a simpler and faster approach would be to use parsers directly, for example: JSON.stringify(JSON.parse(packageLock), undefined, space) Note that in order to support Yarn and pnpm, a Yaml parser would be necessary, and to support Bun, a proprietary binary parser would be necessary. Alternatively we could call out to different package managers, but I don't think there's a unified API for all lockfiles yet. |
Hi, thank you for writing such a useful library. I got one little thing to suggest so I dropped by here.
I have upgraded with the following versions by running
npx browserslist@latest --update-db
:Everything just seems to be working fine. However I found that the entire lines in
package-lock.json
are perceived to be changed by Git due to indentation. In the screen capture below, right side is after upgrading; Left is before. As you can see, there is no practical change, but it seems thatcaniuse-lite
would write output with a default indentation of 2 spaces, regardless of any existing indentation (which in my case was tab).To help understand even more easily, I just copied & pasted the files.
Before running
npx browserslist@latest --update-db
After running
So.. down to the conclusion: it would be nice if
npx browserslist@latest --update-db
could preserve any existing indentation mechanism to help deduce only useful diffs.But after a little inspection into the source code.. I wonder if
npx browserslist@latest --update-db
actually makes a change inpackage-lock.json
? Could it be something else causing the problem?The text was updated successfully, but these errors were encountered: