forked from facebook-atom/nuclide-prebuilt-libs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfind-binary.js
43 lines (37 loc) · 1.04 KB
/
find-binary.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
34
35
36
37
38
39
40
41
42
43
'use strict';
var fs = require('fs');
var path = require('path');
module.exports = function findBinary(packageJsonPath) {
var pack = JSON.parse(fs.readFileSync(packageJsonPath));
// ABI versions 49, 50, 53 are only for Electron.
// https://github.com/electron/electron/issues/5851
var nodeAbi;
switch (process.versions.modules) {
case '49':
nodeAbi = 'electron-v1.3';
break;
case '50':
nodeAbi = 'electron-v1.4';
break;
case '53':
nodeAbi = 'electron-v1.6';
break;
case '54':
nodeAbi = 'electron-v1.7';
break;
default:
nodeAbi = 'node-v' + process.versions.modules;
}
var modulePath = pack.binary.module_path
.replace('{module_name}', pack.binary.module_name)
.replace('{version}', pack.version)
.replace('{node_abi}', nodeAbi)
.replace('{platform}', process.platform)
.replace('{arch}', process.arch);
var resolvedPath = path.join(
path.dirname(packageJsonPath),
modulePath,
pack.binary.module_name + '.node'
);
return resolvedPath;
};