fsevents 1.2.11 → 1.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/node_modules/abbrev/package.json +1 -1
- package/node_modules/ansi-regex/package.json +1 -1
- package/node_modules/aproba/package.json +1 -1
- package/node_modules/are-we-there-yet/package.json +1 -1
- package/node_modules/balanced-match/package.json +1 -1
- package/node_modules/brace-expansion/package.json +1 -1
- package/node_modules/chownr/chownr.js +58 -16
- package/node_modules/chownr/package.json +13 -10
- package/node_modules/code-point-at/package.json +1 -1
- package/node_modules/concat-map/package.json +1 -1
- package/node_modules/console-control-strings/package.json +1 -1
- package/node_modules/core-util-is/package.json +1 -1
- package/node_modules/debug/package.json +1 -1
- package/node_modules/deep-extend/package.json +1 -1
- package/node_modules/delegates/package.json +1 -1
- package/node_modules/detect-libc/package.json +2 -2
- package/node_modules/fs-minipass/package.json +1 -1
- package/node_modules/fs.realpath/package.json +1 -1
- package/node_modules/gauge/package.json +1 -1
- package/node_modules/glob/package.json +1 -1
- package/node_modules/has-unicode/package.json +1 -1
- package/node_modules/iconv-lite/package.json +1 -1
- package/node_modules/ignore-walk/package.json +1 -1
- package/node_modules/inflight/package.json +1 -1
- package/node_modules/inherits/package.json +1 -1
- package/node_modules/ini/package.json +1 -1
- package/node_modules/is-fullwidth-code-point/package.json +1 -1
- package/node_modules/isarray/package.json +1 -1
- package/node_modules/minimatch/package.json +1 -1
- package/node_modules/minimist/.travis.yml +4 -0
- package/node_modules/minimist/example/parse.js +1 -1
- package/node_modules/minimist/index.js +112 -54
- package/node_modules/minimist/package.json +17 -14
- package/node_modules/minimist/readme.markdown +28 -6
- package/node_modules/{rc/node_modules/minimist → minimist}/test/all_bool.js +0 -0
- package/node_modules/{rc/node_modules/minimist → minimist}/test/bool.js +12 -0
- package/node_modules/minimist/test/dash.js +7 -0
- package/node_modules/minimist/test/default_bool.js +15 -0
- package/node_modules/minimist/test/dotted.js +6 -0
- package/node_modules/{rc/node_modules/minimist → minimist}/test/kv_short.js +0 -0
- package/node_modules/{rc/node_modules/minimist → minimist}/test/num.js +0 -0
- package/node_modules/minimist/test/parse.js +23 -144
- package/node_modules/minimist/test/parse_modified.js +1 -1
- package/node_modules/minimist/test/proto.js +44 -0
- package/node_modules/{rc/node_modules/minimist → minimist}/test/stop_early.js +0 -0
- package/node_modules/{rc/node_modules/minimist → minimist}/test/unknown.js +0 -0
- package/node_modules/minipass/package.json +1 -1
- package/node_modules/minizlib/package.json +1 -1
- package/node_modules/mkdirp/package.json +17 -10
- package/node_modules/ms/package.json +1 -1
- package/node_modules/needle/.github/workflows/nodejs.yml +27 -0
- package/node_modules/needle/README.md +5 -5
- package/node_modules/needle/lib/needle.js +9 -3
- package/node_modules/needle/package.json +7 -7
- package/node_modules/needle/test/compression_spec.js +18 -0
- package/node_modules/node-pre-gyp/package.json +9 -8
- package/node_modules/nopt/lib/nopt.js +6 -1
- package/node_modules/nopt/package.json +15 -8
- package/node_modules/npm-bundled/package.json +1 -1
- package/node_modules/npm-normalize-package-bin/package.json +3 -2
- package/node_modules/npm-packlist/package.json +8 -7
- package/node_modules/npmlog/package.json +1 -1
- package/node_modules/number-is-nan/package.json +1 -1
- package/node_modules/object-assign/package.json +1 -1
- package/node_modules/once/package.json +1 -1
- package/node_modules/os-homedir/package.json +1 -1
- package/node_modules/os-tmpdir/package.json +1 -1
- package/node_modules/osenv/package.json +1 -1
- package/node_modules/path-is-absolute/package.json +1 -1
- package/node_modules/process-nextick-args/package.json +1 -1
- package/node_modules/rc/package.json +2 -2
- package/node_modules/readable-stream/.travis.yml +9 -30
- package/node_modules/readable-stream/lib/_stream_duplex.js +1 -1
- package/node_modules/readable-stream/lib/_stream_passthrough.js +1 -1
- package/node_modules/readable-stream/lib/_stream_readable.js +1 -1
- package/node_modules/readable-stream/lib/_stream_transform.js +1 -1
- package/node_modules/readable-stream/lib/_stream_writable.js +1 -1
- package/node_modules/readable-stream/package.json +6 -6
- package/node_modules/rimraf/package.json +2 -2
- package/node_modules/safe-buffer/package.json +1 -1
- package/node_modules/safer-buffer/package.json +1 -1
- package/node_modules/sax/package.json +1 -1
- package/node_modules/semver/package.json +2 -2
- package/node_modules/set-blocking/package.json +1 -1
- package/node_modules/signal-exit/package.json +1 -1
- package/node_modules/string-width/package.json +1 -1
- package/node_modules/string_decoder/package.json +1 -1
- package/node_modules/strip-ansi/package.json +1 -1
- package/node_modules/strip-json-comments/package.json +1 -1
- package/node_modules/tar/package.json +1 -1
- package/node_modules/util-deprecate/package.json +1 -1
- package/node_modules/wide-align/package.json +1 -1
- package/node_modules/wrappy/package.json +1 -1
- package/node_modules/yallist/package.json +1 -1
- package/package.json +2 -2
- package/node_modules/mkdirp/.travis.yml +0 -8
- package/node_modules/mkdirp/examples/pow.js +0 -6
- package/node_modules/mkdirp/test/chmod.js +0 -41
- package/node_modules/mkdirp/test/clobber.js +0 -38
- package/node_modules/mkdirp/test/mkdirp.js +0 -28
- package/node_modules/mkdirp/test/opts_fs.js +0 -29
- package/node_modules/mkdirp/test/opts_fs_sync.js +0 -27
- package/node_modules/mkdirp/test/perm.js +0 -32
- package/node_modules/mkdirp/test/perm_sync.js +0 -36
- package/node_modules/mkdirp/test/race.js +0 -37
- package/node_modules/mkdirp/test/rel.js +0 -32
- package/node_modules/mkdirp/test/return.js +0 -25
- package/node_modules/mkdirp/test/return_sync.js +0 -24
- package/node_modules/mkdirp/test/root.js +0 -19
- package/node_modules/mkdirp/test/sync.js +0 -32
- package/node_modules/mkdirp/test/umask.js +0 -28
- package/node_modules/mkdirp/test/umask_sync.js +0 -32
- package/node_modules/nopt/.npmignore +0 -1
- package/node_modules/nopt/.travis.yml +0 -8
- package/node_modules/nopt/examples/my-program.js +0 -30
- package/node_modules/nopt/test/basic.js +0 -303
- package/node_modules/rc/node_modules/minimist/.travis.yml +0 -8
- package/node_modules/rc/node_modules/minimist/LICENSE +0 -18
- package/node_modules/rc/node_modules/minimist/example/parse.js +0 -2
- package/node_modules/rc/node_modules/minimist/index.js +0 -236
- package/node_modules/rc/node_modules/minimist/package.json +0 -73
- package/node_modules/rc/node_modules/minimist/readme.markdown +0 -91
- package/node_modules/rc/node_modules/minimist/test/dash.js +0 -31
- package/node_modules/rc/node_modules/minimist/test/default_bool.js +0 -35
- package/node_modules/rc/node_modules/minimist/test/dotted.js +0 -22
- package/node_modules/rc/node_modules/minimist/test/long.js +0 -31
- package/node_modules/rc/node_modules/minimist/test/parse.js +0 -197
- package/node_modules/rc/node_modules/minimist/test/parse_modified.js +0 -9
- package/node_modules/rc/node_modules/minimist/test/short.js +0 -67
- package/node_modules/rc/node_modules/minimist/test/whitespace.js +0 -8
@@ -1,15 +1,19 @@
|
|
1
1
|
module.exports = function (args, opts) {
|
2
2
|
if (!opts) opts = {};
|
3
3
|
|
4
|
-
var flags = { bools : {}, strings : {} };
|
5
|
-
|
6
|
-
|
7
|
-
flags.
|
8
|
-
}
|
9
|
-
|
10
|
-
[]
|
11
|
-
|
12
|
-
}
|
4
|
+
var flags = { bools : {}, strings : {}, unknownFn: null };
|
5
|
+
|
6
|
+
if (typeof opts['unknown'] === 'function') {
|
7
|
+
flags.unknownFn = opts['unknown'];
|
8
|
+
}
|
9
|
+
|
10
|
+
if (typeof opts['boolean'] === 'boolean' && opts['boolean']) {
|
11
|
+
flags.allBools = true;
|
12
|
+
} else {
|
13
|
+
[].concat(opts['boolean']).filter(Boolean).forEach(function (key) {
|
14
|
+
flags.bools[key] = true;
|
15
|
+
});
|
16
|
+
}
|
13
17
|
|
14
18
|
var aliases = {};
|
15
19
|
Object.keys(opts.alias || {}).forEach(function (key) {
|
@@ -20,7 +24,14 @@ module.exports = function (args, opts) {
|
|
20
24
|
}));
|
21
25
|
});
|
22
26
|
});
|
23
|
-
|
27
|
+
|
28
|
+
[].concat(opts.string).filter(Boolean).forEach(function (key) {
|
29
|
+
flags.strings[key] = true;
|
30
|
+
if (aliases[key]) {
|
31
|
+
flags.strings[aliases[key]] = true;
|
32
|
+
}
|
33
|
+
});
|
34
|
+
|
24
35
|
var defaults = opts['default'] || {};
|
25
36
|
|
26
37
|
var argv = { _ : [] };
|
@@ -35,7 +46,16 @@ module.exports = function (args, opts) {
|
|
35
46
|
args = args.slice(0, args.indexOf('--'));
|
36
47
|
}
|
37
48
|
|
38
|
-
function
|
49
|
+
function argDefined(key, arg) {
|
50
|
+
return (flags.allBools && /^--[^=]+$/.test(arg)) ||
|
51
|
+
flags.strings[key] || flags.bools[key] || aliases[key];
|
52
|
+
}
|
53
|
+
|
54
|
+
function setArg (key, val, arg) {
|
55
|
+
if (arg && flags.unknownFn && !argDefined(key, arg)) {
|
56
|
+
if (flags.unknownFn(arg) === false) return;
|
57
|
+
}
|
58
|
+
|
39
59
|
var value = !flags.strings[key] && isNumber(val)
|
40
60
|
? Number(val) : val
|
41
61
|
;
|
@@ -45,7 +65,41 @@ module.exports = function (args, opts) {
|
|
45
65
|
setKey(argv, x.split('.'), value);
|
46
66
|
});
|
47
67
|
}
|
68
|
+
|
69
|
+
function setKey (obj, keys, value) {
|
70
|
+
var o = obj;
|
71
|
+
for (var i = 0; i < keys.length-1; i++) {
|
72
|
+
var key = keys[i];
|
73
|
+
if (key === '__proto__') return;
|
74
|
+
if (o[key] === undefined) o[key] = {};
|
75
|
+
if (o[key] === Object.prototype || o[key] === Number.prototype
|
76
|
+
|| o[key] === String.prototype) o[key] = {};
|
77
|
+
if (o[key] === Array.prototype) o[key] = [];
|
78
|
+
o = o[key];
|
79
|
+
}
|
80
|
+
|
81
|
+
var key = keys[keys.length - 1];
|
82
|
+
if (key === '__proto__') return;
|
83
|
+
if (o === Object.prototype || o === Number.prototype
|
84
|
+
|| o === String.prototype) o = {};
|
85
|
+
if (o === Array.prototype) o = [];
|
86
|
+
if (o[key] === undefined || flags.bools[key] || typeof o[key] === 'boolean') {
|
87
|
+
o[key] = value;
|
88
|
+
}
|
89
|
+
else if (Array.isArray(o[key])) {
|
90
|
+
o[key].push(value);
|
91
|
+
}
|
92
|
+
else {
|
93
|
+
o[key] = [ o[key], value ];
|
94
|
+
}
|
95
|
+
}
|
48
96
|
|
97
|
+
function aliasIsBoolean(key) {
|
98
|
+
return aliases[key].some(function (x) {
|
99
|
+
return flags.bools[x];
|
100
|
+
});
|
101
|
+
}
|
102
|
+
|
49
103
|
for (var i = 0; i < args.length; i++) {
|
50
104
|
var arg = args[i];
|
51
105
|
|
@@ -54,27 +108,33 @@ module.exports = function (args, opts) {
|
|
54
108
|
// 'dotall' regex modifier. See:
|
55
109
|
// http://stackoverflow.com/a/1068308/13216
|
56
110
|
var m = arg.match(/^--([^=]+)=([\s\S]*)$/);
|
57
|
-
|
111
|
+
var key = m[1];
|
112
|
+
var value = m[2];
|
113
|
+
if (flags.bools[key]) {
|
114
|
+
value = value !== 'false';
|
115
|
+
}
|
116
|
+
setArg(key, value, arg);
|
58
117
|
}
|
59
118
|
else if (/^--no-.+/.test(arg)) {
|
60
119
|
var key = arg.match(/^--no-(.+)/)[1];
|
61
|
-
setArg(key, false);
|
120
|
+
setArg(key, false, arg);
|
62
121
|
}
|
63
122
|
else if (/^--.+/.test(arg)) {
|
64
123
|
var key = arg.match(/^--(.+)/)[1];
|
65
124
|
var next = args[i + 1];
|
66
125
|
if (next !== undefined && !/^-/.test(next)
|
67
126
|
&& !flags.bools[key]
|
68
|
-
&&
|
69
|
-
|
127
|
+
&& !flags.allBools
|
128
|
+
&& (aliases[key] ? !aliasIsBoolean(key) : true)) {
|
129
|
+
setArg(key, next, arg);
|
70
130
|
i++;
|
71
131
|
}
|
72
132
|
else if (/^(true|false)$/.test(next)) {
|
73
|
-
setArg(key, next === 'true');
|
133
|
+
setArg(key, next === 'true', arg);
|
74
134
|
i++;
|
75
135
|
}
|
76
136
|
else {
|
77
|
-
setArg(key, flags.strings[key] ? '' : true);
|
137
|
+
setArg(key, flags.strings[key] ? '' : true, arg);
|
78
138
|
}
|
79
139
|
}
|
80
140
|
else if (/^-[^-]+/.test(arg)) {
|
@@ -85,24 +145,30 @@ module.exports = function (args, opts) {
|
|
85
145
|
var next = arg.slice(j+2);
|
86
146
|
|
87
147
|
if (next === '-') {
|
88
|
-
setArg(letters[j], next)
|
148
|
+
setArg(letters[j], next, arg)
|
89
149
|
continue;
|
90
150
|
}
|
91
151
|
|
152
|
+
if (/[A-Za-z]/.test(letters[j]) && /=/.test(next)) {
|
153
|
+
setArg(letters[j], next.split('=')[1], arg);
|
154
|
+
broken = true;
|
155
|
+
break;
|
156
|
+
}
|
157
|
+
|
92
158
|
if (/[A-Za-z]/.test(letters[j])
|
93
159
|
&& /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) {
|
94
|
-
setArg(letters[j], next);
|
160
|
+
setArg(letters[j], next, arg);
|
95
161
|
broken = true;
|
96
162
|
break;
|
97
163
|
}
|
98
164
|
|
99
165
|
if (letters[j+1] && letters[j+1].match(/\W/)) {
|
100
|
-
setArg(letters[j], arg.slice(j+2));
|
166
|
+
setArg(letters[j], arg.slice(j+2), arg);
|
101
167
|
broken = true;
|
102
168
|
break;
|
103
169
|
}
|
104
170
|
else {
|
105
|
-
setArg(letters[j], flags.strings[letters[j]] ? '' : true);
|
171
|
+
setArg(letters[j], flags.strings[letters[j]] ? '' : true, arg);
|
106
172
|
}
|
107
173
|
}
|
108
174
|
|
@@ -110,23 +176,29 @@ module.exports = function (args, opts) {
|
|
110
176
|
if (!broken && key !== '-') {
|
111
177
|
if (args[i+1] && !/^(-|--)[^-]/.test(args[i+1])
|
112
178
|
&& !flags.bools[key]
|
113
|
-
&& (aliases[key] ? !
|
114
|
-
setArg(key, args[i+1]);
|
179
|
+
&& (aliases[key] ? !aliasIsBoolean(key) : true)) {
|
180
|
+
setArg(key, args[i+1], arg);
|
115
181
|
i++;
|
116
182
|
}
|
117
|
-
else if (args[i+1] &&
|
118
|
-
setArg(key, args[i+1] === 'true');
|
183
|
+
else if (args[i+1] && /^(true|false)$/.test(args[i+1])) {
|
184
|
+
setArg(key, args[i+1] === 'true', arg);
|
119
185
|
i++;
|
120
186
|
}
|
121
187
|
else {
|
122
|
-
setArg(key, flags.strings[key] ? '' : true);
|
188
|
+
setArg(key, flags.strings[key] ? '' : true, arg);
|
123
189
|
}
|
124
190
|
}
|
125
191
|
}
|
126
192
|
else {
|
127
|
-
|
128
|
-
|
129
|
-
|
193
|
+
if (!flags.unknownFn || flags.unknownFn(arg) !== false) {
|
194
|
+
argv._.push(
|
195
|
+
flags.strings['_'] || !isNumber(arg) ? arg : Number(arg)
|
196
|
+
);
|
197
|
+
}
|
198
|
+
if (opts.stopEarly) {
|
199
|
+
argv._.push.apply(argv._, args.slice(i + 1));
|
200
|
+
break;
|
201
|
+
}
|
130
202
|
}
|
131
203
|
}
|
132
204
|
|
@@ -140,9 +212,17 @@ module.exports = function (args, opts) {
|
|
140
212
|
}
|
141
213
|
});
|
142
214
|
|
143
|
-
|
144
|
-
argv
|
145
|
-
|
215
|
+
if (opts['--']) {
|
216
|
+
argv['--'] = new Array();
|
217
|
+
notFlags.forEach(function(key) {
|
218
|
+
argv['--'].push(key);
|
219
|
+
});
|
220
|
+
}
|
221
|
+
else {
|
222
|
+
notFlags.forEach(function(key) {
|
223
|
+
argv._.push(key);
|
224
|
+
});
|
225
|
+
}
|
146
226
|
|
147
227
|
return argv;
|
148
228
|
};
|
@@ -157,31 +237,9 @@ function hasKey (obj, keys) {
|
|
157
237
|
return key in o;
|
158
238
|
}
|
159
239
|
|
160
|
-
function setKey (obj, keys, value) {
|
161
|
-
var o = obj;
|
162
|
-
keys.slice(0,-1).forEach(function (key) {
|
163
|
-
if (o[key] === undefined) o[key] = {};
|
164
|
-
o = o[key];
|
165
|
-
});
|
166
|
-
|
167
|
-
var key = keys[keys.length - 1];
|
168
|
-
if (o[key] === undefined || typeof o[key] === 'boolean') {
|
169
|
-
o[key] = value;
|
170
|
-
}
|
171
|
-
else if (Array.isArray(o[key])) {
|
172
|
-
o[key].push(value);
|
173
|
-
}
|
174
|
-
else {
|
175
|
-
o[key] = [ o[key], value ];
|
176
|
-
}
|
177
|
-
}
|
178
|
-
|
179
240
|
function isNumber (x) {
|
180
241
|
if (typeof x === 'number') return true;
|
181
242
|
if (/^0x[0-9a-f]+$/i.test(x)) return true;
|
182
243
|
return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
|
183
244
|
}
|
184
245
|
|
185
|
-
function longest (xs) {
|
186
|
-
return Math.max.apply(null, xs.map(function (x) { return x.length }));
|
187
|
-
}
|
@@ -1,27 +1,28 @@
|
|
1
1
|
{
|
2
|
-
"_from": "minimist
|
3
|
-
"_id": "minimist@
|
2
|
+
"_from": "minimist@^1.2.5",
|
3
|
+
"_id": "minimist@1.2.5",
|
4
4
|
"_inBundle": false,
|
5
|
-
"_integrity": "
|
5
|
+
"_integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==",
|
6
6
|
"_location": "/minimist",
|
7
7
|
"_phantomChildren": {},
|
8
8
|
"_requested": {
|
9
|
-
"type": "
|
9
|
+
"type": "range",
|
10
10
|
"registry": true,
|
11
|
-
"raw": "minimist
|
11
|
+
"raw": "minimist@^1.2.5",
|
12
12
|
"name": "minimist",
|
13
13
|
"escapedName": "minimist",
|
14
|
-
"rawSpec": "
|
14
|
+
"rawSpec": "^1.2.5",
|
15
15
|
"saveSpec": null,
|
16
|
-
"fetchSpec": "
|
16
|
+
"fetchSpec": "^1.2.5"
|
17
17
|
},
|
18
18
|
"_requiredBy": [
|
19
|
-
"/mkdirp"
|
19
|
+
"/mkdirp",
|
20
|
+
"/rc"
|
20
21
|
],
|
21
|
-
"_resolved": "https://registry.npmjs.org/minimist/-/minimist-
|
22
|
-
"_shasum": "
|
23
|
-
"_spec": "minimist
|
24
|
-
"_where": "/Users/
|
22
|
+
"_resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
|
23
|
+
"_shasum": "67d66014b66a6a8aaa0c083c5fd58df4e4e97602",
|
24
|
+
"_spec": "minimist@^1.2.5",
|
25
|
+
"_where": "/Users/user/Developer/personal/fsevents/node_modules/mkdirp",
|
25
26
|
"author": {
|
26
27
|
"name": "James Halliday",
|
27
28
|
"email": "mail@substack.net",
|
@@ -34,8 +35,9 @@
|
|
34
35
|
"deprecated": false,
|
35
36
|
"description": "parse argument options",
|
36
37
|
"devDependencies": {
|
38
|
+
"covert": "^1.0.0",
|
37
39
|
"tap": "~0.4.0",
|
38
|
-
"tape": "
|
40
|
+
"tape": "^3.5.0"
|
39
41
|
},
|
40
42
|
"homepage": "https://github.com/substack/minimist",
|
41
43
|
"keywords": [
|
@@ -52,6 +54,7 @@
|
|
52
54
|
"url": "git://github.com/substack/minimist.git"
|
53
55
|
},
|
54
56
|
"scripts": {
|
57
|
+
"coverage": "covert test/*.js",
|
55
58
|
"test": "tap test/*.js"
|
56
59
|
},
|
57
60
|
"testling": {
|
@@ -67,5 +70,5 @@
|
|
67
70
|
"opera/12"
|
68
71
|
]
|
69
72
|
},
|
70
|
-
"version": "
|
73
|
+
"version": "1.2.5"
|
71
74
|
}
|
@@ -5,15 +5,11 @@ parse argument options
|
|
5
5
|
This module is the guts of optimist's argument parser without all the
|
6
6
|
fanciful decoration.
|
7
7
|
|
8
|
-
[](http://ci.testling.com/substack/minimist)
|
9
|
-
|
10
|
-
[](http://travis-ci.org/substack/minimist)
|
11
|
-
|
12
8
|
# example
|
13
9
|
|
14
10
|
``` js
|
15
11
|
var argv = require('minimist')(process.argv.slice(2));
|
16
|
-
console.
|
12
|
+
console.log(argv);
|
17
13
|
```
|
18
14
|
|
19
15
|
```
|
@@ -33,6 +29,13 @@ $ node example/parse.js -x 3 -y 4 -n5 -abc --beep=boop foo bar baz
|
|
33
29
|
beep: 'boop' }
|
34
30
|
```
|
35
31
|
|
32
|
+
# security
|
33
|
+
|
34
|
+
Previous versions had a prototype pollution bug that could cause privilege
|
35
|
+
escalation in some circumstances when handling untrusted user input.
|
36
|
+
|
37
|
+
Please use version 1.2.3 or later: https://snyk.io/vuln/SNYK-JS-MINIMIST-559764
|
38
|
+
|
36
39
|
# methods
|
37
40
|
|
38
41
|
``` js
|
@@ -55,10 +58,29 @@ options can be:
|
|
55
58
|
|
56
59
|
* `opts.string` - a string or array of strings argument names to always treat as
|
57
60
|
strings
|
58
|
-
* `opts.boolean` - a string or array of strings to always treat as
|
61
|
+
* `opts.boolean` - a boolean, string or array of strings to always treat as
|
62
|
+
booleans. if `true` will treat all double hyphenated arguments without equal signs
|
63
|
+
as boolean (e.g. affects `--foo`, not `-f` or `--foo=bar`)
|
59
64
|
* `opts.alias` - an object mapping string names to strings or arrays of string
|
60
65
|
argument names to use as aliases
|
61
66
|
* `opts.default` - an object mapping string argument names to default values
|
67
|
+
* `opts.stopEarly` - when true, populate `argv._` with everything after the
|
68
|
+
first non-option
|
69
|
+
* `opts['--']` - when true, populate `argv._` with everything before the `--`
|
70
|
+
and `argv['--']` with everything after the `--`. Here's an example:
|
71
|
+
|
72
|
+
```
|
73
|
+
> require('./')('one two three -- four five --six'.split(' '), { '--': true })
|
74
|
+
{ _: [ 'one', 'two', 'three' ],
|
75
|
+
'--': [ 'four', 'five', '--six' ] }
|
76
|
+
```
|
77
|
+
|
78
|
+
Note that with `opts['--']` set, parsing for arguments still stops after the
|
79
|
+
`--`.
|
80
|
+
|
81
|
+
* `opts.unknown` - a function which is invoked with a command line parameter not
|
82
|
+
defined in the `opts` configuration object. If the function returns `false`, the
|
83
|
+
unknown option is not added to `argv`.
|
62
84
|
|
63
85
|
# install
|
64
86
|
|
File without changes
|
@@ -164,3 +164,15 @@ test('boolean --boool=false', function (t) {
|
|
164
164
|
t.same(parsed.boool, false);
|
165
165
|
t.end();
|
166
166
|
});
|
167
|
+
|
168
|
+
test('boolean using something similar to true', function (t) {
|
169
|
+
var opts = { boolean: 'h' };
|
170
|
+
var result = parse(['-h', 'true.txt'], opts);
|
171
|
+
var expected = {
|
172
|
+
h: true,
|
173
|
+
'_': ['true.txt']
|
174
|
+
};
|
175
|
+
|
176
|
+
t.same(result, expected);
|
177
|
+
t.end();
|
178
|
+
});
|
@@ -22,3 +22,10 @@ test('-a -- b', function (t) {
|
|
22
22
|
t.deepEqual(parse([ '--a', '--', 'b' ]), { a: true, _: [ 'b' ] });
|
23
23
|
t.deepEqual(parse([ '--a', '--', 'b' ]), { a: true, _: [ 'b' ] });
|
24
24
|
});
|
25
|
+
|
26
|
+
test('move arguments after the -- into their own `--` array', function(t) {
|
27
|
+
t.plan(1);
|
28
|
+
t.deepEqual(
|
29
|
+
parse([ '--name', 'John', 'before', '--', 'after' ], { '--': true }),
|
30
|
+
{ name: 'John', _: [ 'before' ], '--': [ 'after' ] });
|
31
|
+
});
|
@@ -18,3 +18,18 @@ test('boolean default false', function (t) {
|
|
18
18
|
t.equal(argv.somefalse, false);
|
19
19
|
t.end();
|
20
20
|
});
|
21
|
+
|
22
|
+
test('boolean default to null', function (t) {
|
23
|
+
var argv = parse([], {
|
24
|
+
boolean: 'maybe',
|
25
|
+
default: { maybe: null }
|
26
|
+
});
|
27
|
+
t.equal(argv.maybe, null);
|
28
|
+
var argv = parse(['--maybe'], {
|
29
|
+
boolean: 'maybe',
|
30
|
+
default: { maybe: null }
|
31
|
+
});
|
32
|
+
t.equal(argv.maybe, true);
|
33
|
+
t.end();
|
34
|
+
|
35
|
+
})
|
File without changes
|
File without changes
|
@@ -42,32 +42,6 @@ test('comprehensive', function (t) {
|
|
42
42
|
t.end();
|
43
43
|
});
|
44
44
|
|
45
|
-
test('nums', function (t) {
|
46
|
-
var argv = parse([
|
47
|
-
'-x', '1234',
|
48
|
-
'-y', '5.67',
|
49
|
-
'-z', '1e7',
|
50
|
-
'-w', '10f',
|
51
|
-
'--hex', '0xdeadbeef',
|
52
|
-
'789'
|
53
|
-
]);
|
54
|
-
t.deepEqual(argv, {
|
55
|
-
x : 1234,
|
56
|
-
y : 5.67,
|
57
|
-
z : 1e7,
|
58
|
-
w : '10f',
|
59
|
-
hex : 0xdeadbeef,
|
60
|
-
_ : [ 789 ]
|
61
|
-
});
|
62
|
-
t.deepEqual(typeof argv.x, 'number');
|
63
|
-
t.deepEqual(typeof argv.y, 'number');
|
64
|
-
t.deepEqual(typeof argv.z, 'number');
|
65
|
-
t.deepEqual(typeof argv.w, 'string');
|
66
|
-
t.deepEqual(typeof argv.hex, 'number');
|
67
|
-
t.deepEqual(typeof argv._[0], 'number');
|
68
|
-
t.end();
|
69
|
-
});
|
70
|
-
|
71
45
|
test('flag boolean', function (t) {
|
72
46
|
var argv = parse([ '-t', 'moo' ], { boolean: 't' });
|
73
47
|
t.deepEqual(argv, { t : true, _ : [ 'moo' ] });
|
@@ -92,42 +66,6 @@ test('flag boolean value', function (t) {
|
|
92
66
|
t.end();
|
93
67
|
});
|
94
68
|
|
95
|
-
test('flag boolean default false', function (t) {
|
96
|
-
var argv = parse(['moo'], {
|
97
|
-
boolean: ['t', 'verbose'],
|
98
|
-
default: { verbose: false, t: false }
|
99
|
-
});
|
100
|
-
|
101
|
-
t.deepEqual(argv, {
|
102
|
-
verbose: false,
|
103
|
-
t: false,
|
104
|
-
_: ['moo']
|
105
|
-
});
|
106
|
-
|
107
|
-
t.deepEqual(typeof argv.verbose, 'boolean');
|
108
|
-
t.deepEqual(typeof argv.t, 'boolean');
|
109
|
-
t.end();
|
110
|
-
|
111
|
-
});
|
112
|
-
|
113
|
-
test('boolean groups', function (t) {
|
114
|
-
var argv = parse([ '-x', '-z', 'one', 'two', 'three' ], {
|
115
|
-
boolean: ['x','y','z']
|
116
|
-
});
|
117
|
-
|
118
|
-
t.deepEqual(argv, {
|
119
|
-
x : true,
|
120
|
-
y : false,
|
121
|
-
z : true,
|
122
|
-
_ : [ 'one', 'two', 'three' ]
|
123
|
-
});
|
124
|
-
|
125
|
-
t.deepEqual(typeof argv.x, 'boolean');
|
126
|
-
t.deepEqual(typeof argv.y, 'boolean');
|
127
|
-
t.deepEqual(typeof argv.z, 'boolean');
|
128
|
-
t.end();
|
129
|
-
});
|
130
|
-
|
131
69
|
test('newlines in params' , function (t) {
|
132
70
|
var args = parse([ '-s', "X\nX" ])
|
133
71
|
t.deepEqual(args, { _ : [], s : "X\nX" });
|
@@ -183,6 +121,29 @@ test('empty strings', function(t) {
|
|
183
121
|
});
|
184
122
|
|
185
123
|
|
124
|
+
test('string and alias', function(t) {
|
125
|
+
var x = parse([ '--str', '000123' ], {
|
126
|
+
string: 's',
|
127
|
+
alias: { s: 'str' }
|
128
|
+
});
|
129
|
+
|
130
|
+
t.equal(x.str, '000123');
|
131
|
+
t.equal(typeof x.str, 'string');
|
132
|
+
t.equal(x.s, '000123');
|
133
|
+
t.equal(typeof x.s, 'string');
|
134
|
+
|
135
|
+
var y = parse([ '-s', '000123' ], {
|
136
|
+
string: 'str',
|
137
|
+
alias: { str: 's' }
|
138
|
+
});
|
139
|
+
|
140
|
+
t.equal(y.str, '000123');
|
141
|
+
t.equal(typeof y.str, 'string');
|
142
|
+
t.equal(y.s, '000123');
|
143
|
+
t.equal(typeof y.s, 'string');
|
144
|
+
t.end();
|
145
|
+
});
|
146
|
+
|
186
147
|
test('slashBreak', function (t) {
|
187
148
|
t.same(
|
188
149
|
parse([ '-I/foo/bar/baz' ]),
|
@@ -234,85 +195,3 @@ test('nested dotted objects', function (t) {
|
|
234
195
|
t.same(argv.beep, { boop : true });
|
235
196
|
t.end();
|
236
197
|
});
|
237
|
-
|
238
|
-
test('boolean and alias with chainable api', function (t) {
|
239
|
-
var aliased = [ '-h', 'derp' ];
|
240
|
-
var regular = [ '--herp', 'derp' ];
|
241
|
-
var opts = {
|
242
|
-
herp: { alias: 'h', boolean: true }
|
243
|
-
};
|
244
|
-
var aliasedArgv = parse(aliased, {
|
245
|
-
boolean: 'herp',
|
246
|
-
alias: { h: 'herp' }
|
247
|
-
});
|
248
|
-
var propertyArgv = parse(regular, {
|
249
|
-
boolean: 'herp',
|
250
|
-
alias: { h: 'herp' }
|
251
|
-
});
|
252
|
-
var expected = {
|
253
|
-
herp: true,
|
254
|
-
h: true,
|
255
|
-
'_': [ 'derp' ]
|
256
|
-
};
|
257
|
-
|
258
|
-
t.same(aliasedArgv, expected);
|
259
|
-
t.same(propertyArgv, expected);
|
260
|
-
t.end();
|
261
|
-
});
|
262
|
-
|
263
|
-
test('boolean and alias with options hash', function (t) {
|
264
|
-
var aliased = [ '-h', 'derp' ];
|
265
|
-
var regular = [ '--herp', 'derp' ];
|
266
|
-
var opts = {
|
267
|
-
alias: { 'h': 'herp' },
|
268
|
-
boolean: 'herp'
|
269
|
-
};
|
270
|
-
var aliasedArgv = parse(aliased, opts);
|
271
|
-
var propertyArgv = parse(regular, opts);
|
272
|
-
var expected = {
|
273
|
-
herp: true,
|
274
|
-
h: true,
|
275
|
-
'_': [ 'derp' ]
|
276
|
-
};
|
277
|
-
t.same(aliasedArgv, expected);
|
278
|
-
t.same(propertyArgv, expected);
|
279
|
-
t.end();
|
280
|
-
});
|
281
|
-
|
282
|
-
test('boolean and alias using explicit true', function (t) {
|
283
|
-
var aliased = [ '-h', 'true' ];
|
284
|
-
var regular = [ '--herp', 'true' ];
|
285
|
-
var opts = {
|
286
|
-
alias: { h: 'herp' },
|
287
|
-
boolean: 'h'
|
288
|
-
};
|
289
|
-
var aliasedArgv = parse(aliased, opts);
|
290
|
-
var propertyArgv = parse(regular, opts);
|
291
|
-
var expected = {
|
292
|
-
herp: true,
|
293
|
-
h: true,
|
294
|
-
'_': [ ]
|
295
|
-
};
|
296
|
-
|
297
|
-
t.same(aliasedArgv, expected);
|
298
|
-
t.same(propertyArgv, expected);
|
299
|
-
t.end();
|
300
|
-
});
|
301
|
-
|
302
|
-
// regression, see https://github.com/substack/node-optimist/issues/71
|
303
|
-
test('boolean and --x=true', function(t) {
|
304
|
-
var parsed = parse(['--boool', '--other=true'], {
|
305
|
-
boolean: 'boool'
|
306
|
-
});
|
307
|
-
|
308
|
-
t.same(parsed.boool, true);
|
309
|
-
t.same(parsed.other, 'true');
|
310
|
-
|
311
|
-
parsed = parse(['--boool', '--other=false'], {
|
312
|
-
boolean: 'boool'
|
313
|
-
});
|
314
|
-
|
315
|
-
t.same(parsed.boool, true);
|
316
|
-
t.same(parsed.other, 'false');
|
317
|
-
t.end();
|
318
|
-
});
|