Skip to content

fix: make postinstall cross-platform#262

Open
adliebe wants to merge 1 commit into
profullstack:masterfrom
adliebe:fix/windows-postinstall-true
Open

fix: make postinstall cross-platform#262
adliebe wants to merge 1 commit into
profullstack:masterfrom
adliebe:fix/windows-postinstall-true

Conversation

@adliebe
Copy link
Copy Markdown

@adliebe adliebe commented May 27, 2026

Fixes #261.

This replaces the root postinstall shell chain with a small cross-platform Node script.

Why:

  • the current script ends with Unix-only || true
  • on Windows, the fallback can fail with 'true' is not recognized as an internal or external command
  • Socket patching and Git hook setup are best-effort setup steps, so failure there should warn and continue instead of breaking install

What changed:

  • package.json now runs node scripts/postinstall.mjs
  • scripts/postinstall.mjs runs Socket patching best-effort
  • if the checkout is inside a Git repo, it configures core.hooksPath hooks best-effort
  • no app runtime code is touched

Validation run on Windows:

  • node --check scripts/postinstall.mjs
  • node scripts/postinstall.mjs
  • prettier --check package.json scripts/postinstall.mjs
  • git diff --check -- package.json scripts/postinstall.mjs

Submitted 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

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 27, 2026

Greptile Summary

This PR replaces the Unix-only postinstall shell one-liner with a small Node.js script (scripts/postinstall.mjs) that runs the same two setup steps — Socket package patching and Git hooks configuration — on both Unix and Windows.

  • Socket patching (pnpm dlx @socketsecurity/socket-patch apply) and Git hook setup (git config core.hooksPath hooks) are now both wrapped in a best-effort helper that warns on failure instead of hard-failing install.
  • A quoteCmdArg helper handles Windows cmd.exe escaping when spawning processes on Win32; all current argument strings fall into the "safe" path and bypass quoting entirely.

Confidence Score: 5/5

Safe 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

Filename Overview
scripts/postinstall.mjs New cross-platform postinstall script using spawnSync; handles Windows via cmd.exe wrapper with arg quoting, runs Socket patching and Git hooks setup best-effort.
package.json postinstall replaced with node scripts/postinstall.mjs; no other changes.

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
Loading

Reviews (2): Last reviewed commit: "fix: make postinstall cross-platform" | Re-trigger Greptile

Comment thread scripts/postinstall.mjs Outdated
Comment thread scripts/postinstall.mjs Outdated
@adliebe adliebe force-pushed the fix/windows-postinstall-true branch from 64eac84 to aaa935c Compare May 27, 2026 09:50
@adliebe
Copy link
Copy Markdown
Author

adliebe commented May 27, 2026

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.

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.

postinstall fails on Windows because Unix true is not available

1 participant