diff --git a/package.json b/package.json index d823bd8..24e0838 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,8 @@ "src/pwa/icons/", "README.md", "CHANGELOG.md", - "LICENSE" + "LICENSE", + "scripts/postinstall.mjs" ], "publishConfig": { "provenance": true @@ -55,7 +56,8 @@ "test:pw:chromium": "playwright test --project=chromium-android", "test:pw:webkit": "playwright test --project=webkit-iphone", "release": "semantic-release", - "prepublishOnly": "pnpm run lint:ox && pnpm run lint:knip && pnpm run build:dist && pnpm run lint:publint" + "prepublishOnly": "pnpm run lint:ox && pnpm run lint:knip && pnpm run build:dist && pnpm run lint:publint", + "postinstall": "node scripts/postinstall.mjs" }, "devDependencies": { "@biomejs/biome": "^1.9.0", diff --git a/scripts/postinstall.mjs b/scripts/postinstall.mjs new file mode 100644 index 0000000..472d575 --- /dev/null +++ b/scripts/postinstall.mjs @@ -0,0 +1,17 @@ +// Workaround for microsoft/node-pty#850 — spawn-helper prebuild ships without +// execute permission on macOS, causing "posix_spawnp failed" at runtime. +// Remove this script once node-pty >=1.2.0 stable is released and we upgrade. +import { chmodSync, existsSync } from 'node:fs' +import { createRequire } from 'node:module' +import { dirname, join } from 'node:path' + +const require = createRequire(import.meta.url) +try { + const ptyDir = dirname(require.resolve('node-pty/package.json')) + for (const arch of ['darwin-arm64', 'darwin-x64']) { + const helper = join(ptyDir, 'prebuilds', arch, 'spawn-helper') + if (existsSync(helper)) chmodSync(helper, 0o755) + } +} catch { + // node-pty not found, skip +}