forked from mscdex/ssh2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.js
33 lines (29 loc) · 907 Bytes
/
install.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
'use strict';
// This allows someone to disable this script for this repository only.
// npm/yarn/pnpm only allow you to disable install scripts globally.
if (process.env.SSH2_NODE_PURE_JS_ONLY) {
exit(0);
}
const { spawnSync } = require('child_process');
const forceFailOnNonZero = (process.env.CI_CHECK_FAIL === 'ssh2');
// Attempt to build the bundled optional binding
const args = [
`--target=${process.version}`,
`--real_openssl_major=${/^\d+/.exec(process.versions.openssl)[0]}`,
'rebuild',
];
const result = spawnSync('node-gyp', args, {
cwd: 'lib/protocol/crypto',
encoding: 'utf8',
shell: true,
stdio: 'inherit',
windowsHide: true,
});
if (result.error || result.status !== 0) {
console.log('Failed to build optional crypto binding');
if (forceFailOnNonZero)
process.exit(1);
} else {
console.log('Succeeded in building optional crypto binding');
}
process.exit(0);