-
-
Notifications
You must be signed in to change notification settings - Fork 49
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: Only format changed files with Prettier #670
Conversation
…ified / created.
|
src/utils/clack-utils.ts
Outdated
} | ||
}); | ||
childProcess.exec( | ||
`npx prettier --write ${prettierSupportsCache ? '--cache' : ''} .`, |
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.
Does this work if users themselves didn't use --cache
before? Reading the documentation, I'm not sure because it sounds like a cache already needs to be populated so that a file is skipped.
I'm not really worried about the performance aspect but rather that we format files that users (for whatever reason) haven't formatted before or don't want formatted.
If --cache
works for first-time use, no worries, we can use it! Otherwise: We already have some logic around detecting new and changed files via git at the beginning of the wizard. Maybe we could re-use that?
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.
Yes, you're right. I thought a cache was populated anyway via regular prettier
use. But it looks like it was a leftover.
I have switched to using git
. Thanks for pointing that out!
cache
option to only format files that are modified / createdThere 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.
Tested it with a SvelteKit project. Worked like a charm. Thanks Onur (and sorry for the wait, I was ooo last week).
Following up on #644
Formatting changed/untracked files only with Prettier.