-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
169 lines (155 loc) · 3.42 KB
/
index.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
'use strict'
/* -----------------------------------------------------------------------------
* nodeflags
* -------------------------------------------------------------------------- */
// 3rd party
var _ = require('lodash')
var v8flags = require('v8flags')
var semver = require('semver')
/* -----------------------------------------------------------------------------
* nodeflags
* -------------------------------------------------------------------------- */
module.exports = function (includeCommands, callback) {
if (!callback) {
callback = includeCommands
includeCommands = false
}
var version = process.version.substr(1)
var nodeflags = _.assign({}, options, includeCommands ? commands : {})
v8flags(function (err, flags) {
if (err) {
return callback(err)
}
// transform v8flags array to keyed object
flags = _.reduce(flags, function (flags, flag) {
flags[flag.substr(2)] = { type: 'boolean' }
return flags
}, {})
flags = _.pickBy(_.assign(flags, nodeflags), function (flag, key) {
// v8flags don't need to be versioned as they are auto generated base on
// current version
return flag._version
? semver.gte(version, flag._version)
: true
})
callback(null, flags)
})
}
// irrelevant in the context of proxying args which is the primary reasoning
// behind the creation of this module
var commands = {
'version': {
type: 'boolean',
alias: 'v',
_version: '0.1.3'
},
'help': {
type: 'boolean',
alias: 'h',
_version: '0.1.3'
},
'eval': {
type: 'string',
alias: 'e',
_version: '0.5.2'
},
'print': {
type: 'boolean',
alias: 'p',
_version: '0.6.4'
},
'check': {
type: 'boolean',
alias: 'c',
_version: '5.0.0'
},
'interactive': {
type: 'boolean',
alias: 'i',
_version: '0.7.7'
},
'v8-options': {
type: 'boolean',
_version: '0.1.3'
}
}
var options = {
'require': {
type: 'string',
alias: 'r',
_version: '1.6.0'
},
'no-deprecation': {
type: 'boolean',
_version: '0.8.0'
},
'trace-deprecation': {
type: 'boolean',
_version: '0.8.0'
},
'throw-deprecation': {
type: 'boolean',
_version: '0.11.14'
},
'no-warnings': {
type: 'boolean',
_version: '6.0.0'
},
'trace-warnings': {
type: 'boolean',
_version: '6.0.0'
},
'trace-sync-io': {
type: 'boolean',
_version: '2.1.0'
},
'track-heap-objects': {
type: 'boolean',
_version: '2.4.0'
},
'prof-process': {
type: 'boolean',
_version: '6.0.0'
},
'zero-fill-buffers': {
type: 'boolean',
_version: '6.0.0'
},
'tls-cipher-list': {
type: 'string',
_version: '4.0.0'
},
'openssl-config': {
type: 'string',
_version: '6.9.0'
},
'icu-data-dir': {
type: 'string',
_version: '0.11.15'
},
'preserve-symlinks': {
type: 'boolean',
_version: '6.3.0'
},
// included in docs but not help (const custom node compile)
'enable-fips': {
type: 'boolean',
_version: '6.0.0'
},
'force-fips': {
type: 'boolean',
_version: '6.0.0'
},
// included in --help but not docs
'v8-pool-size': {
type: 'number',
// https://github.com/nodejs/node/pull/5970
_version: '5.10.0'
},
// undocumented
'debug-brk': {
type: 'boolean',
// https://github.com/nodejs/node/commit/8a15147bc53849417f8737dd873877d497867c9f
_version: '0.7.7'
}
}