-
Notifications
You must be signed in to change notification settings - Fork 37
/
bin.js
executable file
·52 lines (41 loc) · 1.11 KB
/
bin.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
44
45
46
47
48
49
50
51
52
#!/usr/bin/env node
var minimist = require('minimist')
var abi = require('node-abi')
var prebuildify = require('./index')
var argv = minimist(process.argv.slice(2), {
alias: {target: 't', version: 'v', all: 'a', napi: 'n-api'},
boolean: ['quiet', 'strip']
})
var targets = [].concat(argv.target || []).map(function (v) {
if (v.indexOf('@') === -1) v = 'node@' + v
return {
runtime: v.split('@')[0],
target: v.split('@')[1].replace(/^v/, '')
}
})
// TODO: also support --lts and get versions from travis
if (argv.all) {
targets = abi.supportedTargets.slice(0)
}
// Should be the default once napi is stable
if (argv.napi) {
targets = [
abi.supportedTargets.filter(onlyNode).pop(),
abi.supportedTargets.filter(onlyElectron).pop(),
]
if (targets[0].target === '9.0.0') targets[0].target = '9.6.1'
}
argv.targets = targets
argv.cwd = argv.cwd || argv._[0] || '.'
prebuildify(argv, function (err) {
if (err) {
console.error(err.message || err)
process.exit(1)
}
})
function onlyNode (t) {
return t.runtime === 'node'
}
function onlyElectron (t) {
return t.runtime === 'electron'
}