Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Fix pnpm format:changed #53404

Merged
merged 1 commit into from
Jun 13, 2023
Merged

Fix pnpm format:changed #53404

merged 1 commit into from
Jun 13, 2023

Conversation

camdencheek
Copy link
Member

@camdencheek camdencheek commented Jun 13, 2023

Sequence of events:

  • I run pnpm format
  • I get annoyed that it's slow
  • I want a command that just runs over the diff from main
  • I look in package.json and see that it already exists
  • I try to use it, but it fails because the grep filter only applies to the second command
  • I create this PR to fix the issue

Test plan

Ran pnpm format:changed and it works on my local branch now.

@cla-bot cla-bot bot added the cla-signed label Jun 13, 2023
@camdencheek camdencheek requested a review from a team June 13, 2023 17:19
@jhchabran jhchabran requested a review from valerybugakov June 13, 2023 17:20
@@ -12,7 +12,7 @@
},
"scripts": {
"format": "prettier '**/{*.{js?(on),ts?(x),graphql,md,scss},.*.js?(on)}' --list-different --config prettier.config.js --write",
"format:changed": "prettier $(git diff --diff-filter=d --name-only origin/main... && git ls-files --other --modified --exclude-standard | grep -E '\\.(js|json|ts|tsx|graphql|md|scss)$' | xargs) --write --list-different --config prettier.config.js",
"format:changed": "prettier $( { git diff --diff-filter=d --name-only origin/main... && git ls-files --other --modified --exclude-standard ; } | grep -E '\\.(js|json|ts|tsx|graphql|md|scss)$' | xargs) --write --list-different --config prettier.config.js",
Copy link
Member Author

@camdencheek camdencheek Jun 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously, grep would only apply to the second git command here, so the output of git diff would spit out files that prettier could not handle. This just wraps the two git commands in a block so their output will both be filtered by the grep command.

@camdencheek camdencheek enabled auto-merge (squash) June 13, 2023 17:23
@sourcegraph-bot
Copy link
Contributor

📖 Storybook live preview

@camdencheek camdencheek merged commit 244120b into main Jun 13, 2023
@camdencheek camdencheek deleted the cc/fix-format-changed branch June 13, 2023 17:36
ErikaRS pushed a commit that referenced this pull request Jun 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants