Skip to content

fix(dev): make native git hooks work on Windows#2013

Open
BittuBarnwal7479 wants to merge 5 commits into
cedarjs:mainfrom
BittuBarnwal7479:fix/window-smart-format-issue
Open

fix(dev): make native git hooks work on Windows#2013
BittuBarnwal7479 wants to merge 5 commits into
cedarjs:mainfrom
BittuBarnwal7479:fix/window-smart-format-issue

Conversation

@BittuBarnwal7479

Copy link
Copy Markdown
Contributor

Summary

Fixes a few Windows issues in the new native git hooks.

The hooks now:

  • run Yarn correctly on Windows
  • format staged files without Unix-only quoting
  • skip agent doc symlinks that Prettier sees incorrectly on Windows
  • build before linting in pre-push, so lint does not read missing dist files

Testing

Tested on Windows:

  • node tasks/git-hooks/pre-commit.mts
  • node tasks/git-hooks/pre-push.mts
  • git push origin HEAD

All hooks passed.

@netlify

netlify Bot commented Jun 27, 2026

Copy link
Copy Markdown

👷 Deploy request for cedarjs pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit e1be0ab

@github-actions github-actions Bot added this to the next-release-patch milestone Jun 27, 2026
@greptile-apps

greptile-apps Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR updates the native git hooks to work better on Windows.

  • Windows Yarn calls go through cmd.exe and yarn.cmd.
  • Pre-push runs build before lint, prettier, and check.
  • Prettier ignores root agent instruction placeholders.
  • Smart formatting changes staged-file quoting on Windows.

Confidence Score: 4/5

The Windows staged-file formatting path needs a fix before merging.

  • Hook build ordering and Yarn wrapping look contained.
  • The formatter now passes unquoted Windows paths through a shell command string.
  • Staged files with spaces can be split into wrong arguments.

tasks/smart-format.mts

Important Files Changed

Filename Overview
.prettierignore Adds root-level Prettier ignores for agent instruction placeholder files.
tasks/git-hooks/pre-push.mts Runs build first, then runs lint, prettier, and check only after build succeeds.
tasks/git-hooks/shared.mts Adds a Windows-specific Yarn command wrapper for shared hook execution.
tasks/smart-format.mts Changes Windows formatting paths to a raw space-joined command string, which breaks paths containing spaces.

Reviews (1): Last reviewed commit: "fix(dev): run hook build before lint" | Re-trigger Greptile

Comment thread tasks/smart-format.mts
@@ -61,5 +61,9 @@ if (existingFiles.length > 0) {
}

function quoteAll(files: string[]): string {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Windows Paths Split Apart

When a staged Windows file path contains a space, this joins it into the shell command without quoting. A path like web/src/My Component.tsx is split into separate arguments, so the pre-commit formatter can fail or format the wrong targets instead of formatting the staged file.

@nx-cloud

nx-cloud Bot commented Jun 27, 2026

Copy link
Copy Markdown

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit e1be0ab


☁️ Nx Cloud last updated this comment at 2026-06-27 13:01:44 UTC

@nx-cloud

nx-cloud Bot commented Jun 27, 2026

Copy link
Copy Markdown

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit e1be0ab

Command Status Duration Result
nx run-many -t test --minWorkers=1 --maxWorkers=4 ✅ Succeeded 7s View ↗
nx run-many -t test:types ✅ Succeeded 11s View ↗
nx run-many -t build:pack --exclude create-ceda... ✅ Succeeded 4s View ↗
nx run-many -t build ✅ Succeeded 5s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-06-27 13:08:55 UTC

@Tobbe

Tobbe commented Jun 27, 2026

Copy link
Copy Markdown
Member

@BittuBarnwal7479 Can you please explain more about your Windows setup?

Are you using WSL or GitForWindows (MSysGit)?
How did you install corepack?
How did you install yarn?
What's your global yarn version?
What's the yarn version reported inside the framework monorepo?
What's your terminal?
What's your shell?

Thanks for helping fix these Windows issues! 🙏

@BittuBarnwal7479

Copy link
Copy Markdown
Contributor Author

@BittuBarnwal7479 Can you please explain more about your Windows setup?

Are you using WSL or GitForWindows (MSysGit)? How did you install corepack? How did you install yarn? What's your global yarn version? What's the yarn version reported inside the framework monorepo? What's your terminal? What's your shell?

Thanks for helping fix these Windows issues! 🙏

i am not using wsl for this testing, i am using native windows.

  • OS: Windows
  • Git: Git for Windows
  • Terminal: Windows Terminal / PowerShell
  • Shell: PowerShell
  • Node: Node 24.x
  • Corepack: came with Node, but I had to use the repo shim path to make sure Yarn 4 was picked up
  • Global Yarn: 1.22.22
  • Yarn inside the Cedar monorepo: 4.14.1

in inside the repo i use:

$env:Path = "D:\cedar\.yarn\shims;$env:Path"
yarn --version

@Tobbe

Tobbe commented Jun 27, 2026

Copy link
Copy Markdown
Member

Can you try using Git Bash instead of PowerShell please? See if that helps

@BittuBarnwal7479

BittuBarnwal7479 commented Jun 27, 2026

Copy link
Copy Markdown
Contributor Author

Can you try using Git Bash instead of PowerShell please? See if that helps

Sure, I'll try it in Git Bash instead of PowerShell, I need a little more time. I'm just wrapping up another cool project using n8n. 🙂
Thanks for your patience!

@Tobbe

Tobbe commented Jun 27, 2026

Copy link
Copy Markdown
Member

No rush at all :)

@BittuBarnwal7479

Copy link
Copy Markdown
Contributor Author

Can you try using Git Bash instead of PowerShell please? See if that helps

tested with Git Bash as well.

it correctly handles the single-quoted Prettier glob, but I still hit spawnSync yarn ENOENT when Node uses spawn('yarn', ..., { shell: false }) on Windows. So it fixes quoting, but not the Yarn spawn issue.

With this branch, both hooks ran successfully:

node tasks/git-hooks/pre-commit.mts
node tasks/git-hooks/pre-push.mts

So I think the Windows-specific hook handling is still useful for native Windows users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants