You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Prettier currently supports any number of targets in the same CLI command. For example this command will format file1.ts and file2.ts but ignore anything else that might happen to be in that directory:
prettier --write file1.ts file2.ts
You can add any number of target files or directories this way. This is particularly useful when adding prettier into a precommit hook, so that you can format only files that have been modified in this commit. Take this precommit for example, which only formats staged files:
#!/bin/sh
LC_ALL=C
# Select files to format
FILES=$(git diff --cached --name-only --diff-filter=ACM | sed 's| |\\ |g')
[ -z"$FILES" ] &&exit 0
# Prettier format selected files # Appends filenames to the end of `npx prettier --write`echo"$FILES"| cat | xargs npx prettier --write
# Add back the modified files to stageecho"$FILES"| xargs git add
exit 0
Is there any chance of that being added as a feature for csharpier? It'd be great to add this tool to my precommit hooks.
The text was updated successfully, but these errors were encountered:
I think this is a great idea and shouldn't take too much effort to add.
First pass would probably just support [file/directory] but I think it'll make sense long term to support [file/directory/glob] just like prettier does.
Prettier currently supports any number of targets in the same CLI command. For example this command will format
file1.ts
andfile2.ts
but ignore anything else that might happen to be in that directory:You can add any number of target files or directories this way. This is particularly useful when adding prettier into a precommit hook, so that you can format only files that have been modified in this commit. Take this precommit for example, which only formats staged files:
Is there any chance of that being added as a feature for csharpier? It'd be great to add this tool to my precommit hooks.
The text was updated successfully, but these errors were encountered: