This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

fix: make postinstall spawn-helper chmod work under pnpm GVS (#8)

Fix node-pty spawn-helper chmod for pnpm GVS layouts

The previous postinstall used a relative path that silently no-op'd
under pnpm's global virtual store. Replace with a proper Node.js
script that uses createRequire + require.resolve to find node-pty
regardless of install layout.

Credit: @schickling

authored by

Johannes Schickling and committed by
GitHub
(Apr 7, 2026, 3:22 PM +0200) fbefdfa1 699a44ae

+48 -1
+2 -1
package.json
··· 22 22 "dist/", 23 23 "completions/", 24 24 "docs/", 25 + "scripts/postinstall.js", 25 26 "README.md", 26 27 "LICENSE" 27 28 ], ··· 45 46 "scripts": { 46 47 "build": "tsc -p tsconfig.build.json", 47 48 "prepublishOnly": "npm run build", 48 - "postinstall": "chmod +x node_modules/node-pty/prebuilds/*/spawn-helper 2>/dev/null || true", 49 + "postinstall": "node scripts/postinstall.js", 49 50 "prepare": "git config core.hooksPath githooks 2>/dev/null || true; sh scripts/update-nix-hash.sh 2>/dev/null || true", 50 51 "install-completions": "sh scripts/install-completions.sh", 51 52 "typecheck": "tsc",
+46
scripts/postinstall.js
··· 1 + // Ensure node-pty's prebuilt `spawn-helper` is executable. Necessary because 2 + // node-pty's published tarball ships the file with mode 0644 and its own 3 + // post-install never chmods it. The previous workaround used a relative path 4 + // (`node_modules/node-pty/prebuilds/*/spawn-helper`) which silently no-ops 5 + // under pnpm with `enableGlobalVirtualStore`, where node-pty lives in a 6 + // sibling content-addressed link rather than nested under @myobie/pty. 7 + // 8 + // The root-cause fix belongs in microsoft/node-pty; once that ships, this 9 + // script can be removed entirely. 10 + 11 + import * as fs from "node:fs"; 12 + import * as path from "node:path"; 13 + import { createRequire } from "node:module"; 14 + import { pathToFileURL } from "node:url"; 15 + 16 + if (process.platform === "win32") process.exit(0); 17 + 18 + // Resolve from this package's root (package.json sibling), not from the 19 + // script file, so that node-pty is discoverable regardless of whether 20 + // node_modules is nested (npm/yarn/bun) or a sibling link (pnpm GVS). 21 + const pkgDir = path.dirname(new URL(import.meta.url).pathname); 22 + const requireFromPkg = createRequire( 23 + pathToFileURL(path.join(pkgDir, "..", "package.json")), 24 + ); 25 + 26 + let nodePtyDir; 27 + try { 28 + nodePtyDir = path.dirname(requireFromPkg.resolve("node-pty/package.json")); 29 + } catch { 30 + console.warn("[@myobie/pty] node-pty not found; skipping spawn-helper chmod"); 31 + process.exit(0); 32 + } 33 + 34 + const helper = path.join( 35 + nodePtyDir, 36 + "prebuilds", 37 + `${process.platform}-${process.arch}`, 38 + "spawn-helper", 39 + ); 40 + 41 + try { 42 + fs.chmodSync(helper, 0o755); 43 + } catch { 44 + // Acceptable when there's no prebuild for this arch and node-pty was 45 + // built from source — node-gyp produces the binary executable already. 46 + }