Skip to content

Commit b5ef3a3

Browse files
committed
fix postinstall
1 parent 776568b commit b5ef3a3

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

build/postinstall.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,32 @@
11
import child_process from 'node:child_process';
22

3+
import DEBUG from 'debug';
4+
35
import {execute} from './execute.js';
46
import {isMac} from './constants.js';
7+
import {exists} from './utils.js';
8+
9+
const debug = DEBUG('postinstall');
510

611
async function main() {
712
if (isMac) {
8-
const result = child_process.execFileSync('xattr', ['-l', 'dist/darwin-universal.dawn.node']);
9-
if (!result.toString().includes('com.apple.quarantine')) {
13+
const dawnNode = 'dist/darwin-universal.dawn.node';
14+
const attribute = 'com.apple.quarantine'
15+
if (!exists(dawnNode)) {
16+
debug(`${dawnNode} does not exist`);
17+
return;
18+
}
19+
20+
const result = child_process.execFileSync('xattr', ['-l', dawnNode], {encoding: 'utf8'});
21+
if (!result.includes(attribute)) {
22+
debug(`${dawnNode} does not have attribute: ${attribute}`);
1023
return;
1124
}
1225

1326
// The user has already indicated they trust this by installing it,
1427
// This executable can not do anything a JavaScript node script couldn't also do.
15-
await execute('xattr', ['-d', 'com.apple.quarantine', 'dist/darwin-universal.dawn.node']);
28+
await execute('xattr', ['-d', attribute, dawnNode]);
29+
console.log(`removed attribute: ${attribute}`);
1630
}
1731
}
1832

0 commit comments

Comments
 (0)