-
Notifications
You must be signed in to change notification settings - Fork 146
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
feat: use Prettier to write config file, if possible #356
feat: use Prettier to write config file, if possible #356
Conversation
@all-contributors Please add @JoshuaKGoldberg for ideas and code |
I've put up a pull request to add @JoshuaKGoldberg! 🎉 |
🎉 This PR is included in version 6.26.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Not sure it's fully related (I'm still investigating) but when passing from 6.25.0 to 6.26.0 of the project the command UPDATE 1 No issue with version 6.25.1. Issue starts at 6.26.0. |
@@ -43,7 +44,7 @@ function writeConfig(configPath, content) { | |||
`Error! Project files was overridden and is empty in ${configPath}`, | |||
) | |||
} | |||
return pify(fs.writeFile)(configPath, `${JSON.stringify(content, null, 2)}\n`) | |||
return pify(fs.writeFile)(configPath, `${formatConfig(content)}\n`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that we pass the content as config, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we are replacing this code by JSON.stringify(undefined, null, 2)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🌷🌷
The change all-contributors#356 seem to break the formatting of the file .all-contributorsrc. Instead of formatting the content, it formats "undefined". See: - all-contributors#356 (comment) - all-contributors#356 (comment)
What: If the user has the
prettier
package available in their project and has a Prettier config file (e.g..prettierrc.json
), Prettier will be used to write.allcontributorsrc
files.Why: See #347.
How: Adds
prettier
as an optional dependency. Augments the config writing logic to:require('prettier')
prettier.resolveConfigFile.sync
...falling back to the traditional
JSON.stringify(content, null, 2)
if any of that fails.Checklist:
Are
optionalDependencies
the way to go? I can never keep track of the latest preferences around optionals/peers/etc.