Skip to content

Commit b971db1

Browse files
authored
fix: posix_spawnp failed on macos (#22)
1 parent 7441b32 commit b971db1

2 files changed

Lines changed: 21 additions & 2 deletions

File tree

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
"src/pwa/icons/",
2626
"README.md",
2727
"CHANGELOG.md",
28-
"LICENSE"
28+
"LICENSE",
29+
"scripts/postinstall.mjs"
2930
],
3031
"publishConfig": {
3132
"provenance": true
@@ -55,7 +56,8 @@
5556
"test:pw:chromium": "playwright test --project=chromium-android",
5657
"test:pw:webkit": "playwright test --project=webkit-iphone",
5758
"release": "semantic-release",
58-
"prepublishOnly": "pnpm run lint:ox && pnpm run lint:knip && pnpm run build:dist && pnpm run lint:publint"
59+
"prepublishOnly": "pnpm run lint:ox && pnpm run lint:knip && pnpm run build:dist && pnpm run lint:publint",
60+
"postinstall": "node scripts/postinstall.mjs"
5961
},
6062
"devDependencies": {
6163
"@biomejs/biome": "^1.9.0",

scripts/postinstall.mjs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Workaround for microsoft/node-pty#850 — spawn-helper prebuild ships without
2+
// execute permission on macOS, causing "posix_spawnp failed" at runtime.
3+
// Remove this script once node-pty >=1.2.0 stable is released and we upgrade.
4+
import { chmodSync, existsSync } from 'node:fs'
5+
import { createRequire } from 'node:module'
6+
import { dirname, join } from 'node:path'
7+
8+
const require = createRequire(import.meta.url)
9+
try {
10+
const ptyDir = dirname(require.resolve('node-pty/package.json'))
11+
for (const arch of ['darwin-arm64', 'darwin-x64']) {
12+
const helper = join(ptyDir, 'prebuilds', arch, 'spawn-helper')
13+
if (existsSync(helper)) chmodSync(helper, 0o755)
14+
}
15+
} catch {
16+
// node-pty not found, skip
17+
}

0 commit comments

Comments
 (0)