Repository navigation
fix: make lefthook prepare guard work under cmd.exe on Windows - #284
Merged
Merged
Conversation
pnpm/npm run lifecycle scripts through cmd.exe on Windows by default, where `command -v` and `/dev/null` do not exist. The previous guard errored and fell through to `|| true`, exiting 0 without installing the hook, so Windows developers silently got no secret scanning. `git --version && lefthook install || exit 0` has the same semantics (skip entirely when git is absent, never fail the install) and works in both cmd.exe and POSIX sh.
Collaborator
Author
|
/gcbrun |
pwei1018
approved these changes
Sep 28, 2026
Collaborator
|
Temporary Url for review: https://yfthig-dev--pr-284-kjy4e9jz.web.app |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #282, part of the Git Hooks RFC rollout (bcgov/entity#34619).
Problem
The
prepareguard from #282 silently skips installing the hook on Windows:pnpm/npm run lifecycle scripts through
cmd.exeon Windows by default.command -vand/dev/nulldon't exist there, so it prints "The system cannot find the path specified", falls through to|| true, and the install exits 0 with no hook installed. Windows devs get no secret scanning and nothing telling them so.Fix
Same semantics as #282 (don't attempt lefthook at all when git is absent, e.g. the Cloud Build CD image; never fail the install) but works in both
cmd.exeand POSIXsh.Verified
pnpm run prepareon Windows), git present: hook installedgit commitwith a fake GitHub token on Windows: blocked by gitleaksSame change pushed to bcgov/ppr#2377 and bcgov/namex#2019.