|
1 | 1 | import child_process from 'node:child_process'; |
2 | 2 |
|
| 3 | +import DEBUG from 'debug'; |
| 4 | + |
3 | 5 | import {execute} from './execute.js'; |
4 | 6 | import {isMac} from './constants.js'; |
| 7 | +import {exists} from './utils.js'; |
| 8 | + |
| 9 | +const debug = DEBUG('postinstall'); |
5 | 10 |
|
6 | 11 | async function main() { |
7 | 12 | 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}`); |
10 | 23 | return; |
11 | 24 | } |
12 | 25 |
|
13 | 26 | // The user has already indicated they trust this by installing it, |
14 | 27 | // 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}`); |
16 | 30 | } |
17 | 31 | } |
18 | 32 |
|
|
0 commit comments