fix: fall back to oxfmt or skip when prettier cannot format changelog#145
Conversation
npx -y prettier fails in pnpm projects where prettier is only a transitive dependency: npm sees the package in the node_modules tree, skips the download, then cannot find the bin on PATH (pnpm only links bins for direct dependencies). Chain fallbacks so the release does not fail over changelog formatting. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Warning Review the following alerts detected in dependencies. According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.
|
Problem
Releases fail in repos where prettier is not a direct dependency, for example this get-it run:
Failure mode
npx -yis supposed to download prettier when it is missing, but it does not in this scenario. The failing combination is:node_modules/.pnpm/prettier@x.y.zWhen
npx -y prettierruns, npm scans the actualnode_modulestree, finds a package namedprettierin the pnpm store, and concludes it is already installed locally - so it skips the download. It then executesprettier --write CHANGELOG.mdthroughsh, expecting the bin to be on PATH. But pnpm only links bins for direct dependencies intonode_modules/.bin, so there is noprettierexecutable anywhere on PATH:sh: 1: prettier: not found, exit 127.This is deterministic, not stale cache: reproduced in a clean
node:22container with a pnpm project that has prettier only as a transitive dependency. The same setup installed with npm works fine, since npm hoists transitive bins differently.Fix
Chain fallbacks in the
prepareCmd:-bullets, collapsed whitespace)Verification
All paths tested through
sh -cthe same way@semantic-release/execruns the command:node:22container (pnpm, transitive prettier, direct oxfmt dep): prettier branch fails withprettier: not found, oxfmt branch finds the locally linked bin and formats CHANGELOG.md correctly, exit 0🤖 Generated with Claude Code