fix: make postinstall cross-platform#262
Conversation
Greptile SummaryThis PR replaces the Unix-only
Confidence Score: 5/5Safe to merge — the change is self-contained to install-time tooling and touches no app runtime code. Both setup steps (Socket patching and Git hooks) are now genuinely best-effort and will warn instead of breaking install on any platform. The Windows cmd.exe escaping in quoteCmdArg covers all characters actually used by the current call sites; the missing % escape is theoretical given the args in use. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A([npm/pnpm install]) --> B[node scripts/postinstall.mjs]
B --> C{platform win32?}
C -- yes --> D[cmd.exe /d /s /c ...]
C -- no --> E[spawnSync directly]
D --> F[runBestEffort: pnpm dlx socket-patch apply]
E --> F
F --> G{error or non-zero exit?}
G -- yes --> H[console.warn & continue]
G -- no --> I[Socket patching OK]
H --> J[git rev-parse --is-inside-work-tree]
I --> J
J --> K{error or status != 0?}
K -- yes --> L([Done — skip hooks])
K -- no --> M[runBestEffort: git config core.hooksPath hooks]
M --> N{error or non-zero exit?}
N -- yes --> O[console.warn & continue]
N -- no --> P([Git hooks configured])
O --> P
Reviews (2): Last reviewed commit: "fix: make postinstall cross-platform" | Re-trigger Greptile |
64eac84 to
aaa935c
Compare
|
Pushed aaa935c to address the Greptile robustness nits: Windows command args are now quoted before going through cmd.exe, and the git-repo probe checks both error and status before configuring hooks. |
Fixes #261.
This replaces the root
postinstallshell chain with a small cross-platform Node script.Why:
|| true'true' is not recognized as an internal or external commandWhat changed:
package.jsonnow runsnode scripts/postinstall.mjsscripts/postinstall.mjsruns Socket patching best-effortcore.hooksPath hooksbest-effortValidation run on Windows:
node --check scripts/postinstall.mjsnode scripts/postinstall.mjsprettier --check package.json scripts/postinstall.mjsgit diff --check -- package.json scripts/postinstall.mjsSubmitted for the active Ugig request to test the repo, file a bug, and submit a PR fix: https://ugig.net/gigs/abd6b2a0-e728-48cf-a46f-f99e419ed94e
Bug report: #261