-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
Add possibility to change detectIndent option #16
Comments
I think it would be better to fix your specific issue instead. We could just default to 2-space indentation if the existing indentation could not be detected. |
|
Actually, I do think its better to fix this using the linked PR. I can give you another use case - you can have badly indented There may be another use cases, I do think it's a better idea to give control and choice to a developer. I've changed the issue name, maybe it gave false meaning, the PR doesn't remove default |
The linked PR is not fixing it. It's giving you the ability to work around it. That's different. I want to actually fix it so everyone doesn't have to specify the option to get the expected behavior when the package.json is empty.
I'm not a big fan of doing changes based on imaginary scenarios. There's also no |
Oh, I see what you mean, totally understandable :)
I'm using indent option from write-json-file, which sets indentation to No matter what indentation is in existing file, set indentation to 2 spaces. It works with I see by default you set Suggest how to solve this to work both ways, I'll update PR :) |
So, I see a fix in two parts:
@sindresorhus what do you think? |
Sorry, I totally missed your comment. Yes, that plan sounds good. |
Hey 👋
Internal
write-json-file
has a detectIndent option to detect indentation of existing file which isfalse
by default.write-pkg
provides this option which is hardcoded totrue
.If existing file has empty
{}
contents inside, added fields will be saved as a single line:It's impossible to fix such file indentation using any indentation options, the only way is to remove file and regenerate it. It would be nice to have
detectIndent
not hardcoded and have possibility to overwrite it.The text was updated successfully, but these errors were encountered: