Skip to content

Commit 3701df9

Browse files
authored
Fix macOS code-signing (#19)
1 parent 1544c73 commit 3701df9

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

fix-python-soname.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,26 @@ async function runSonameFixer() {
9898
});
9999

100100
// Run the WASI module
101-
process.exit(wasi.start(instance))
101+
const exitCode = wasi.start(instance)
102+
if (exitCode !== 0) {
103+
console.error(`Error: soname fixer exited with code ${exitCode}`)
104+
process.exit(exitCode)
105+
}
106+
107+
// On macOS, re-sign the binary after patching
108+
if (platform === 'darwin') {
109+
console.log('Re-signing binary after patching...')
110+
const { execSync } = require('child_process')
111+
try {
112+
execSync(`codesign --force --sign - "${nodeFilePath}"`, { stdio: 'inherit' })
113+
console.log('Binary re-signed successfully')
114+
} catch (error) {
115+
console.error('Warning: Failed to re-sign binary:', error.message)
116+
// Don't fail the install if codesign fails - the binary might still work
117+
}
118+
}
119+
120+
process.exit(0)
102121
} catch (error) {
103122
console.error('Error: Failed to run soname fixer:', error.message)
104123
process.exit(1) // Fail hard when installed as dependency

0 commit comments

Comments
 (0)