Repository navigation
feat: Only format changed files with Prettier - #670
Conversation
…ified / created.
|
| } | ||
| }); | ||
| childProcess.exec( | ||
| `npx prettier --write ${prettierSupportsCache ? '--cache' : ''} .`, |
There was a problem hiding this comment.
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.
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 / created
Lms24
left a comment
There was a problem hiding this comment.
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.