2 Commits

Author SHA1 Message Date
jiarung
d3971e77fd fix(git-hooks): replace GNU-only sort -V with portable zero-pad sort
sort -V is a GNU extension; BSD sort on macOS does not support it. When
node is absent from PATH and the nvm fallback runs, set -euo pipefail
causes the unsupported flag to abort the hook before lint/format can
run, blocking commits on macOS.

Replace the sort -V | tail -1 pipeline with a Bash for-loop that
zero-pads each semver component to five digits and emits a tab-delimited
key+path line. Plain sort + tail -1 + cut then selects the highest
semantic version — no GNU-only flags required.

Smoke-tested with v18 vs v22 paths; v22 is correctly selected on both
GNU and BSD sort.
2026-03-15 05:14:07 +00:00
jiarung
98822509a8 fix(git-hooks): pick newest nvm Node with version-aware sort
The previous loop used Bash glob expansion (lexicographic order) and
stopped at the first match, so environments with multiple Node installs
could select an older runtime (e.g. v18 before v22).

Extract the nvm resolution into a shared scripts/pre-commit/resolve-node.sh
that pipes `ls` output through `sort -V | tail -1` to select the
semantically newest version. Both pre-commit and run-node-tool.sh now
source the shared script, eliminating the duplicated logic.
2026-03-13 14:17:36 +00:00