forked from prebuild/prebuild
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrc.js
82 lines (72 loc) · 1.69 KB
/
rc.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
var minimist = require('minimist')
var targets = require('node-abi').supportedTargets
var detectLibc = require('detect-libc')
var napi = require('napi-build-utils')
var libc = process.env.LIBC || (detectLibc.isNonGlibcLinuxSync() && detectLibc.familySync()) || ''
var rc = require('rc')('prebuild', {
target: process.versions.node,
runtime: 'node',
arch: process.arch,
libc: libc,
platform: process.platform,
all: false,
force: false,
debug: false,
verbose: false,
path: '.',
backend: 'node-gyp',
format: false,
'include-regex': '\\.node$',
'tag-prefix': 'v',
prerelease: false
}, minimist(process.argv, {
alias: {
target: 't',
runtime: 'r',
help: 'h',
arch: 'a',
path: 'p',
force: 'f',
version: 'v',
upload: 'u',
preinstall: 'i',
prepack: 'c'
},
string: [
'target'
]
}))
if (rc.path === true) {
delete rc.path
}
if (napi.isNapiRuntime(rc.runtime) && rc.target === process.versions.node) {
if (rc.all === true) {
rc.target = napi.getNapiBuildVersions()
} else {
rc.target = napi.getBestNapiBuildVersion()
}
}
if (rc.target) {
var arr = [].concat(rc.target)
rc.prebuild = []
for (var k = 0, len = arr.length; k < len; k++) {
if (!napi.isNapiRuntime(rc.runtime) || napi.isSupportedVersion(arr[k])) {
rc.prebuild.push({
runtime: rc.runtime,
target: arr[k]
})
}
}
}
if (rc.all === true && !napi.isNapiRuntime(rc.runtime)) {
delete rc.prebuild
rc.prebuild = targets
}
if (rc['upload-all']) {
rc.upload = rc['upload-all']
}
rc['include-regex'] = new RegExp(rc['include-regex'], 'i')
module.exports = rc
if (!module.parent) {
console.log(JSON.stringify(module.exports, null, 2))
}