cross-spawn-cb 0.5.10 → 0.5.13
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/lib/cross-spawn-3.0.1/index.js +1626 -0
- package/lib/index.js +1 -0
- package/lib/polyfills.js +6 -14
- package/lib/spawn-sync/spawn-sync.js +7 -3
- package/lib/spawn-sync/worker.js +9 -9
- package/lib/spawnCallback.js +2 -1
- package/lib/spawnSyncCallback.js +5 -2
- package/package.json +9 -7
- package/lib/cross-spawn/LICENSE +0 -21
- package/lib/cross-spawn/index.js +0 -654
|
@@ -0,0 +1,1626 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, '__esModule', {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
var require$$0$2 = require('child_process');
|
|
10
|
+
|
|
11
|
+
var require$$0 = require('fs');
|
|
12
|
+
|
|
13
|
+
var require$$1 = require('util');
|
|
14
|
+
|
|
15
|
+
var require$$0$1 = require('path');
|
|
16
|
+
|
|
17
|
+
function _interopDefaultLegacy(e) {
|
|
18
|
+
return e && _typeof(e) === 'object' && 'default' in e ? e : {
|
|
19
|
+
'default': e
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
var require$$0__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$0$2);
|
|
24
|
+
|
|
25
|
+
var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
|
|
26
|
+
|
|
27
|
+
var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
|
|
28
|
+
|
|
29
|
+
var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$1);
|
|
30
|
+
|
|
31
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
32
|
+
var crossSpawn = {
|
|
33
|
+
exports: {}
|
|
34
|
+
};
|
|
35
|
+
var map = {
|
|
36
|
+
exports: {}
|
|
37
|
+
};
|
|
38
|
+
var pseudomap;
|
|
39
|
+
var hasRequiredPseudomap;
|
|
40
|
+
|
|
41
|
+
function requirePseudomap() {
|
|
42
|
+
if (hasRequiredPseudomap) return pseudomap;
|
|
43
|
+
hasRequiredPseudomap = 1;
|
|
44
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
45
|
+
pseudomap = PseudoMap;
|
|
46
|
+
|
|
47
|
+
function PseudoMap(set) {
|
|
48
|
+
if (!(this instanceof PseudoMap)) // whyyyyyyy
|
|
49
|
+
throw new TypeError("Constructor PseudoMap requires 'new'");
|
|
50
|
+
this.clear();
|
|
51
|
+
|
|
52
|
+
if (set) {
|
|
53
|
+
if (set instanceof PseudoMap || typeof Map === 'function' && set instanceof Map) set.forEach(function (value, key) {
|
|
54
|
+
this.set(key, value);
|
|
55
|
+
}, this);else if (Array.isArray(set)) set.forEach(function (kv) {
|
|
56
|
+
this.set(kv[0], kv[1]);
|
|
57
|
+
}, this);else throw new TypeError('invalid argument');
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
PseudoMap.prototype.forEach = function (fn, thisp) {
|
|
62
|
+
thisp = thisp || this;
|
|
63
|
+
Object.keys(this._data).forEach(function (k) {
|
|
64
|
+
if (k !== 'size') fn.call(thisp, this._data[k].value, this._data[k].key);
|
|
65
|
+
}, this);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
PseudoMap.prototype.has = function (k) {
|
|
69
|
+
return !!find(this._data, k);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
PseudoMap.prototype.get = function (k) {
|
|
73
|
+
var res = find(this._data, k);
|
|
74
|
+
return res && res.value;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
PseudoMap.prototype.set = function (k, v) {
|
|
78
|
+
set(this._data, k, v);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
PseudoMap.prototype["delete"] = function (k) {
|
|
82
|
+
var res = find(this._data, k);
|
|
83
|
+
|
|
84
|
+
if (res) {
|
|
85
|
+
delete this._data[res._index];
|
|
86
|
+
this._data.size--;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
PseudoMap.prototype.clear = function () {
|
|
91
|
+
var data = Object.create(null);
|
|
92
|
+
data.size = 0;
|
|
93
|
+
Object.defineProperty(this, '_data', {
|
|
94
|
+
value: data,
|
|
95
|
+
enumerable: false,
|
|
96
|
+
configurable: true,
|
|
97
|
+
writable: false
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
Object.defineProperty(PseudoMap.prototype, 'size', {
|
|
102
|
+
get: function get() {
|
|
103
|
+
return this._data.size;
|
|
104
|
+
},
|
|
105
|
+
set: function set(n) {},
|
|
106
|
+
enumerable: true,
|
|
107
|
+
configurable: true
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
PseudoMap.prototype.values = PseudoMap.prototype.keys = PseudoMap.prototype.entries = function () {
|
|
111
|
+
throw new Error('iterators are not implemented in this version');
|
|
112
|
+
}; // Either identical, or both NaN
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
function same(a, b) {
|
|
116
|
+
return a === b || a !== a && b !== b;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function Entry(k, v, i) {
|
|
120
|
+
this.key = k;
|
|
121
|
+
this.value = v;
|
|
122
|
+
this._index = i;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function find(data, k) {
|
|
126
|
+
for (var i = 0, s = '_' + k, key = s; hasOwnProperty.call(data, key); key = s + i++) {
|
|
127
|
+
if (same(data[key].key, k)) return data[key];
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function set(data, k, v) {
|
|
132
|
+
for (var i = 0, s = '_' + k, key = s; hasOwnProperty.call(data, key); key = s + i++) {
|
|
133
|
+
if (same(data[key].key, k)) {
|
|
134
|
+
data[key].value = v;
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
data.size++;
|
|
140
|
+
data[key] = new Entry(k, v, key);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return pseudomap;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
(function (module) {
|
|
147
|
+
if (process.env.npm_package_name === 'pseudomap' && process.env.npm_lifecycle_script === 'test') process.env.TEST_PSEUDOMAP = 'true';
|
|
148
|
+
|
|
149
|
+
if (typeof Map === 'function' && !process.env.TEST_PSEUDOMAP) {
|
|
150
|
+
module.exports = Map;
|
|
151
|
+
} else {
|
|
152
|
+
module.exports = requirePseudomap();
|
|
153
|
+
}
|
|
154
|
+
})(map);
|
|
155
|
+
|
|
156
|
+
var yallist = Yallist$1;
|
|
157
|
+
Yallist$1.Node = Node;
|
|
158
|
+
Yallist$1.create = Yallist$1;
|
|
159
|
+
|
|
160
|
+
function Yallist$1(list) {
|
|
161
|
+
var self = this;
|
|
162
|
+
|
|
163
|
+
if (!(self instanceof Yallist$1)) {
|
|
164
|
+
self = new Yallist$1();
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
self.tail = null;
|
|
168
|
+
self.head = null;
|
|
169
|
+
self.length = 0;
|
|
170
|
+
|
|
171
|
+
if (list && typeof list.forEach === 'function') {
|
|
172
|
+
list.forEach(function (item) {
|
|
173
|
+
self.push(item);
|
|
174
|
+
});
|
|
175
|
+
} else if (arguments.length > 0) {
|
|
176
|
+
for (var i = 0, l = arguments.length; i < l; i++) {
|
|
177
|
+
self.push(arguments[i]);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return self;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
Yallist$1.prototype.removeNode = function (node) {
|
|
185
|
+
if (node.list !== this) {
|
|
186
|
+
throw new Error('removing node which does not belong to this list');
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
var next = node.next;
|
|
190
|
+
var prev = node.prev;
|
|
191
|
+
|
|
192
|
+
if (next) {
|
|
193
|
+
next.prev = prev;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (prev) {
|
|
197
|
+
prev.next = next;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (node === this.head) {
|
|
201
|
+
this.head = next;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (node === this.tail) {
|
|
205
|
+
this.tail = prev;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
node.list.length--;
|
|
209
|
+
node.next = null;
|
|
210
|
+
node.prev = null;
|
|
211
|
+
node.list = null;
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
Yallist$1.prototype.unshiftNode = function (node) {
|
|
215
|
+
if (node === this.head) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if (node.list) {
|
|
220
|
+
node.list.removeNode(node);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
var head = this.head;
|
|
224
|
+
node.list = this;
|
|
225
|
+
node.next = head;
|
|
226
|
+
|
|
227
|
+
if (head) {
|
|
228
|
+
head.prev = node;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
this.head = node;
|
|
232
|
+
|
|
233
|
+
if (!this.tail) {
|
|
234
|
+
this.tail = node;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
this.length++;
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
Yallist$1.prototype.pushNode = function (node) {
|
|
241
|
+
if (node === this.tail) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
if (node.list) {
|
|
246
|
+
node.list.removeNode(node);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
var tail = this.tail;
|
|
250
|
+
node.list = this;
|
|
251
|
+
node.prev = tail;
|
|
252
|
+
|
|
253
|
+
if (tail) {
|
|
254
|
+
tail.next = node;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
this.tail = node;
|
|
258
|
+
|
|
259
|
+
if (!this.head) {
|
|
260
|
+
this.head = node;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
this.length++;
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
Yallist$1.prototype.push = function () {
|
|
267
|
+
for (var i = 0, l = arguments.length; i < l; i++) {
|
|
268
|
+
push(this, arguments[i]);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
return this.length;
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
Yallist$1.prototype.unshift = function () {
|
|
275
|
+
for (var i = 0, l = arguments.length; i < l; i++) {
|
|
276
|
+
unshift(this, arguments[i]);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
return this.length;
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
Yallist$1.prototype.pop = function () {
|
|
283
|
+
if (!this.tail) {
|
|
284
|
+
return undefined;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
var res = this.tail.value;
|
|
288
|
+
this.tail = this.tail.prev;
|
|
289
|
+
|
|
290
|
+
if (this.tail) {
|
|
291
|
+
this.tail.next = null;
|
|
292
|
+
} else {
|
|
293
|
+
this.head = null;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
this.length--;
|
|
297
|
+
return res;
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
Yallist$1.prototype.shift = function () {
|
|
301
|
+
if (!this.head) {
|
|
302
|
+
return undefined;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
var res = this.head.value;
|
|
306
|
+
this.head = this.head.next;
|
|
307
|
+
|
|
308
|
+
if (this.head) {
|
|
309
|
+
this.head.prev = null;
|
|
310
|
+
} else {
|
|
311
|
+
this.tail = null;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
this.length--;
|
|
315
|
+
return res;
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
Yallist$1.prototype.forEach = function (fn, thisp) {
|
|
319
|
+
thisp = thisp || this;
|
|
320
|
+
|
|
321
|
+
for (var walker = this.head, i = 0; walker !== null; i++) {
|
|
322
|
+
fn.call(thisp, walker.value, i, this);
|
|
323
|
+
walker = walker.next;
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
Yallist$1.prototype.forEachReverse = function (fn, thisp) {
|
|
328
|
+
thisp = thisp || this;
|
|
329
|
+
|
|
330
|
+
for (var walker = this.tail, i = this.length - 1; walker !== null; i--) {
|
|
331
|
+
fn.call(thisp, walker.value, i, this);
|
|
332
|
+
walker = walker.prev;
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
Yallist$1.prototype.get = function (n) {
|
|
337
|
+
for (var i = 0, walker = this.head; walker !== null && i < n; i++) {
|
|
338
|
+
// abort out of the list early if we hit a cycle
|
|
339
|
+
walker = walker.next;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
if (i === n && walker !== null) {
|
|
343
|
+
return walker.value;
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
Yallist$1.prototype.getReverse = function (n) {
|
|
348
|
+
for (var i = 0, walker = this.tail; walker !== null && i < n; i++) {
|
|
349
|
+
// abort out of the list early if we hit a cycle
|
|
350
|
+
walker = walker.prev;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
if (i === n && walker !== null) {
|
|
354
|
+
return walker.value;
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
|
|
358
|
+
Yallist$1.prototype.map = function (fn, thisp) {
|
|
359
|
+
thisp = thisp || this;
|
|
360
|
+
var res = new Yallist$1();
|
|
361
|
+
|
|
362
|
+
for (var walker = this.head; walker !== null;) {
|
|
363
|
+
res.push(fn.call(thisp, walker.value, this));
|
|
364
|
+
walker = walker.next;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
return res;
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
Yallist$1.prototype.mapReverse = function (fn, thisp) {
|
|
371
|
+
thisp = thisp || this;
|
|
372
|
+
var res = new Yallist$1();
|
|
373
|
+
|
|
374
|
+
for (var walker = this.tail; walker !== null;) {
|
|
375
|
+
res.push(fn.call(thisp, walker.value, this));
|
|
376
|
+
walker = walker.prev;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
return res;
|
|
380
|
+
};
|
|
381
|
+
|
|
382
|
+
Yallist$1.prototype.reduce = function (fn, initial) {
|
|
383
|
+
var acc;
|
|
384
|
+
var walker = this.head;
|
|
385
|
+
|
|
386
|
+
if (arguments.length > 1) {
|
|
387
|
+
acc = initial;
|
|
388
|
+
} else if (this.head) {
|
|
389
|
+
walker = this.head.next;
|
|
390
|
+
acc = this.head.value;
|
|
391
|
+
} else {
|
|
392
|
+
throw new TypeError('Reduce of empty list with no initial value');
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
for (var i = 0; walker !== null; i++) {
|
|
396
|
+
acc = fn(acc, walker.value, i);
|
|
397
|
+
walker = walker.next;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
return acc;
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
Yallist$1.prototype.reduceReverse = function (fn, initial) {
|
|
404
|
+
var acc;
|
|
405
|
+
var walker = this.tail;
|
|
406
|
+
|
|
407
|
+
if (arguments.length > 1) {
|
|
408
|
+
acc = initial;
|
|
409
|
+
} else if (this.tail) {
|
|
410
|
+
walker = this.tail.prev;
|
|
411
|
+
acc = this.tail.value;
|
|
412
|
+
} else {
|
|
413
|
+
throw new TypeError('Reduce of empty list with no initial value');
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
for (var i = this.length - 1; walker !== null; i--) {
|
|
417
|
+
acc = fn(acc, walker.value, i);
|
|
418
|
+
walker = walker.prev;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
return acc;
|
|
422
|
+
};
|
|
423
|
+
|
|
424
|
+
Yallist$1.prototype.toArray = function () {
|
|
425
|
+
var arr = new Array(this.length);
|
|
426
|
+
|
|
427
|
+
for (var i = 0, walker = this.head; walker !== null; i++) {
|
|
428
|
+
arr[i] = walker.value;
|
|
429
|
+
walker = walker.next;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
return arr;
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
Yallist$1.prototype.toArrayReverse = function () {
|
|
436
|
+
var arr = new Array(this.length);
|
|
437
|
+
|
|
438
|
+
for (var i = 0, walker = this.tail; walker !== null; i++) {
|
|
439
|
+
arr[i] = walker.value;
|
|
440
|
+
walker = walker.prev;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
return arr;
|
|
444
|
+
};
|
|
445
|
+
|
|
446
|
+
Yallist$1.prototype.slice = function (from, to) {
|
|
447
|
+
to = to || this.length;
|
|
448
|
+
|
|
449
|
+
if (to < 0) {
|
|
450
|
+
to += this.length;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
from = from || 0;
|
|
454
|
+
|
|
455
|
+
if (from < 0) {
|
|
456
|
+
from += this.length;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
var ret = new Yallist$1();
|
|
460
|
+
|
|
461
|
+
if (to < from || to < 0) {
|
|
462
|
+
return ret;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
if (from < 0) {
|
|
466
|
+
from = 0;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
if (to > this.length) {
|
|
470
|
+
to = this.length;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
for (var i = 0, walker = this.head; walker !== null && i < from; i++) {
|
|
474
|
+
walker = walker.next;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
for (; walker !== null && i < to; i++, walker = walker.next) {
|
|
478
|
+
ret.push(walker.value);
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
return ret;
|
|
482
|
+
};
|
|
483
|
+
|
|
484
|
+
Yallist$1.prototype.sliceReverse = function (from, to) {
|
|
485
|
+
to = to || this.length;
|
|
486
|
+
|
|
487
|
+
if (to < 0) {
|
|
488
|
+
to += this.length;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
from = from || 0;
|
|
492
|
+
|
|
493
|
+
if (from < 0) {
|
|
494
|
+
from += this.length;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
var ret = new Yallist$1();
|
|
498
|
+
|
|
499
|
+
if (to < from || to < 0) {
|
|
500
|
+
return ret;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
if (from < 0) {
|
|
504
|
+
from = 0;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
if (to > this.length) {
|
|
508
|
+
to = this.length;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) {
|
|
512
|
+
walker = walker.prev;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
for (; walker !== null && i > from; i--, walker = walker.prev) {
|
|
516
|
+
ret.push(walker.value);
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
return ret;
|
|
520
|
+
};
|
|
521
|
+
|
|
522
|
+
Yallist$1.prototype.reverse = function () {
|
|
523
|
+
var head = this.head;
|
|
524
|
+
var tail = this.tail;
|
|
525
|
+
|
|
526
|
+
for (var walker = head; walker !== null; walker = walker.prev) {
|
|
527
|
+
var p = walker.prev;
|
|
528
|
+
walker.prev = walker.next;
|
|
529
|
+
walker.next = p;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
this.head = tail;
|
|
533
|
+
this.tail = head;
|
|
534
|
+
return this;
|
|
535
|
+
};
|
|
536
|
+
|
|
537
|
+
function push(self, item) {
|
|
538
|
+
self.tail = new Node(item, self.tail, null, self);
|
|
539
|
+
|
|
540
|
+
if (!self.head) {
|
|
541
|
+
self.head = self.tail;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
self.length++;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
function unshift(self, item) {
|
|
548
|
+
self.head = new Node(item, null, self.head, self);
|
|
549
|
+
|
|
550
|
+
if (!self.tail) {
|
|
551
|
+
self.tail = self.head;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
self.length++;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
function Node(value, prev, next, list) {
|
|
558
|
+
if (!(this instanceof Node)) {
|
|
559
|
+
return new Node(value, prev, next, list);
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
this.list = list;
|
|
563
|
+
this.value = value;
|
|
564
|
+
|
|
565
|
+
if (prev) {
|
|
566
|
+
prev.next = this;
|
|
567
|
+
this.prev = prev;
|
|
568
|
+
} else {
|
|
569
|
+
this.prev = null;
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
if (next) {
|
|
573
|
+
next.prev = this;
|
|
574
|
+
this.next = next;
|
|
575
|
+
} else {
|
|
576
|
+
this.next = null;
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
var lruCache = LRUCache; // This will be a proper iterable 'Map' in engines that support it,
|
|
581
|
+
// or a fakey-fake PseudoMap in older versions.
|
|
582
|
+
|
|
583
|
+
var Map$1 = map.exports;
|
|
584
|
+
var util = require$$1__default["default"]; // A linked list to keep track of recently-used-ness
|
|
585
|
+
|
|
586
|
+
var Yallist = yallist; // use symbols if possible, otherwise just _props
|
|
587
|
+
|
|
588
|
+
var hasSymbol = typeof Symbol === 'function' && process.env._nodeLRUCacheForceNoSymbol !== '1';
|
|
589
|
+
var makeSymbol;
|
|
590
|
+
|
|
591
|
+
if (hasSymbol) {
|
|
592
|
+
makeSymbol = function makeSymbol(key) {
|
|
593
|
+
return Symbol(key);
|
|
594
|
+
};
|
|
595
|
+
} else {
|
|
596
|
+
makeSymbol = function makeSymbol(key) {
|
|
597
|
+
return '_' + key;
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
var MAX = makeSymbol('max');
|
|
602
|
+
var LENGTH = makeSymbol('length');
|
|
603
|
+
var LENGTH_CALCULATOR = makeSymbol('lengthCalculator');
|
|
604
|
+
var ALLOW_STALE = makeSymbol('allowStale');
|
|
605
|
+
var MAX_AGE = makeSymbol('maxAge');
|
|
606
|
+
var DISPOSE = makeSymbol('dispose');
|
|
607
|
+
var NO_DISPOSE_ON_SET = makeSymbol('noDisposeOnSet');
|
|
608
|
+
var LRU_LIST = makeSymbol('lruList');
|
|
609
|
+
var CACHE = makeSymbol('cache');
|
|
610
|
+
|
|
611
|
+
function naiveLength() {
|
|
612
|
+
return 1;
|
|
613
|
+
} // lruList is a yallist where the head is the youngest
|
|
614
|
+
// item, and the tail is the oldest. the list contains the Hit
|
|
615
|
+
// objects as the entries.
|
|
616
|
+
// Each Hit object has a reference to its Yallist.Node. This
|
|
617
|
+
// never changes.
|
|
618
|
+
//
|
|
619
|
+
// cache is a Map (or PseudoMap) that matches the keys to
|
|
620
|
+
// the Yallist.Node object.
|
|
621
|
+
|
|
622
|
+
|
|
623
|
+
function LRUCache(options) {
|
|
624
|
+
if (!(this instanceof LRUCache)) {
|
|
625
|
+
return new LRUCache(options);
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
if (typeof options === 'number') {
|
|
629
|
+
options = {
|
|
630
|
+
max: options
|
|
631
|
+
};
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
if (!options) {
|
|
635
|
+
options = {};
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
var max = this[MAX] = options.max; // Kind of weird to have a default max of Infinity, but oh well.
|
|
639
|
+
|
|
640
|
+
if (!max || !(typeof max === 'number') || max <= 0) {
|
|
641
|
+
this[MAX] = Infinity;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
var lc = options.length || naiveLength;
|
|
645
|
+
|
|
646
|
+
if (typeof lc !== 'function') {
|
|
647
|
+
lc = naiveLength;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
this[LENGTH_CALCULATOR] = lc;
|
|
651
|
+
this[ALLOW_STALE] = options.stale || false;
|
|
652
|
+
this[MAX_AGE] = options.maxAge || 0;
|
|
653
|
+
this[DISPOSE] = options.dispose;
|
|
654
|
+
this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false;
|
|
655
|
+
this.reset();
|
|
656
|
+
} // resize the cache when the max changes.
|
|
657
|
+
|
|
658
|
+
|
|
659
|
+
Object.defineProperty(LRUCache.prototype, 'max', {
|
|
660
|
+
set: function set(mL) {
|
|
661
|
+
if (!mL || !(typeof mL === 'number') || mL <= 0) {
|
|
662
|
+
mL = Infinity;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
this[MAX] = mL;
|
|
666
|
+
trim(this);
|
|
667
|
+
},
|
|
668
|
+
get: function get() {
|
|
669
|
+
return this[MAX];
|
|
670
|
+
},
|
|
671
|
+
enumerable: true
|
|
672
|
+
});
|
|
673
|
+
Object.defineProperty(LRUCache.prototype, 'allowStale', {
|
|
674
|
+
set: function set(allowStale) {
|
|
675
|
+
this[ALLOW_STALE] = !!allowStale;
|
|
676
|
+
},
|
|
677
|
+
get: function get() {
|
|
678
|
+
return this[ALLOW_STALE];
|
|
679
|
+
},
|
|
680
|
+
enumerable: true
|
|
681
|
+
});
|
|
682
|
+
Object.defineProperty(LRUCache.prototype, 'maxAge', {
|
|
683
|
+
set: function set(mA) {
|
|
684
|
+
if (!mA || !(typeof mA === 'number') || mA < 0) {
|
|
685
|
+
mA = 0;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
this[MAX_AGE] = mA;
|
|
689
|
+
trim(this);
|
|
690
|
+
},
|
|
691
|
+
get: function get() {
|
|
692
|
+
return this[MAX_AGE];
|
|
693
|
+
},
|
|
694
|
+
enumerable: true
|
|
695
|
+
}); // resize the cache when the lengthCalculator changes.
|
|
696
|
+
|
|
697
|
+
Object.defineProperty(LRUCache.prototype, 'lengthCalculator', {
|
|
698
|
+
set: function set(lC) {
|
|
699
|
+
if (typeof lC !== 'function') {
|
|
700
|
+
lC = naiveLength;
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
if (lC !== this[LENGTH_CALCULATOR]) {
|
|
704
|
+
this[LENGTH_CALCULATOR] = lC;
|
|
705
|
+
this[LENGTH] = 0;
|
|
706
|
+
this[LRU_LIST].forEach(function (hit) {
|
|
707
|
+
hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key);
|
|
708
|
+
this[LENGTH] += hit.length;
|
|
709
|
+
}, this);
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
trim(this);
|
|
713
|
+
},
|
|
714
|
+
get: function get() {
|
|
715
|
+
return this[LENGTH_CALCULATOR];
|
|
716
|
+
},
|
|
717
|
+
enumerable: true
|
|
718
|
+
});
|
|
719
|
+
Object.defineProperty(LRUCache.prototype, 'length', {
|
|
720
|
+
get: function get() {
|
|
721
|
+
return this[LENGTH];
|
|
722
|
+
},
|
|
723
|
+
enumerable: true
|
|
724
|
+
});
|
|
725
|
+
Object.defineProperty(LRUCache.prototype, 'itemCount', {
|
|
726
|
+
get: function get() {
|
|
727
|
+
return this[LRU_LIST].length;
|
|
728
|
+
},
|
|
729
|
+
enumerable: true
|
|
730
|
+
});
|
|
731
|
+
|
|
732
|
+
LRUCache.prototype.rforEach = function (fn, thisp) {
|
|
733
|
+
thisp = thisp || this;
|
|
734
|
+
|
|
735
|
+
for (var walker = this[LRU_LIST].tail; walker !== null;) {
|
|
736
|
+
var prev = walker.prev;
|
|
737
|
+
forEachStep(this, fn, walker, thisp);
|
|
738
|
+
walker = prev;
|
|
739
|
+
}
|
|
740
|
+
};
|
|
741
|
+
|
|
742
|
+
function forEachStep(self, fn, node, thisp) {
|
|
743
|
+
var hit = node.value;
|
|
744
|
+
|
|
745
|
+
if (isStale(self, hit)) {
|
|
746
|
+
del(self, node);
|
|
747
|
+
|
|
748
|
+
if (!self[ALLOW_STALE]) {
|
|
749
|
+
hit = undefined;
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
if (hit) {
|
|
754
|
+
fn.call(thisp, hit.value, hit.key, self);
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
LRUCache.prototype.forEach = function (fn, thisp) {
|
|
759
|
+
thisp = thisp || this;
|
|
760
|
+
|
|
761
|
+
for (var walker = this[LRU_LIST].head; walker !== null;) {
|
|
762
|
+
var next = walker.next;
|
|
763
|
+
forEachStep(this, fn, walker, thisp);
|
|
764
|
+
walker = next;
|
|
765
|
+
}
|
|
766
|
+
};
|
|
767
|
+
|
|
768
|
+
LRUCache.prototype.keys = function () {
|
|
769
|
+
return this[LRU_LIST].toArray().map(function (k) {
|
|
770
|
+
return k.key;
|
|
771
|
+
}, this);
|
|
772
|
+
};
|
|
773
|
+
|
|
774
|
+
LRUCache.prototype.values = function () {
|
|
775
|
+
return this[LRU_LIST].toArray().map(function (k) {
|
|
776
|
+
return k.value;
|
|
777
|
+
}, this);
|
|
778
|
+
};
|
|
779
|
+
|
|
780
|
+
LRUCache.prototype.reset = function () {
|
|
781
|
+
if (this[DISPOSE] && this[LRU_LIST] && this[LRU_LIST].length) {
|
|
782
|
+
this[LRU_LIST].forEach(function (hit) {
|
|
783
|
+
this[DISPOSE](hit.key, hit.value);
|
|
784
|
+
}, this);
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
this[CACHE] = new Map$1(); // hash of items by key
|
|
788
|
+
|
|
789
|
+
this[LRU_LIST] = new Yallist(); // list of items in order of use recency
|
|
790
|
+
|
|
791
|
+
this[LENGTH] = 0; // length of items in the list
|
|
792
|
+
};
|
|
793
|
+
|
|
794
|
+
LRUCache.prototype.dump = function () {
|
|
795
|
+
return this[LRU_LIST].map(function (hit) {
|
|
796
|
+
if (!isStale(this, hit)) {
|
|
797
|
+
return {
|
|
798
|
+
k: hit.key,
|
|
799
|
+
v: hit.value,
|
|
800
|
+
e: hit.now + (hit.maxAge || 0)
|
|
801
|
+
};
|
|
802
|
+
}
|
|
803
|
+
}, this).toArray().filter(function (h) {
|
|
804
|
+
return h;
|
|
805
|
+
});
|
|
806
|
+
};
|
|
807
|
+
|
|
808
|
+
LRUCache.prototype.dumpLru = function () {
|
|
809
|
+
return this[LRU_LIST];
|
|
810
|
+
};
|
|
811
|
+
/* istanbul ignore next */
|
|
812
|
+
|
|
813
|
+
|
|
814
|
+
LRUCache.prototype.inspect = function (n, opts) {
|
|
815
|
+
var str = 'LRUCache {';
|
|
816
|
+
var extras = false;
|
|
817
|
+
var as = this[ALLOW_STALE];
|
|
818
|
+
|
|
819
|
+
if (as) {
|
|
820
|
+
str += '\n allowStale: true';
|
|
821
|
+
extras = true;
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
var max = this[MAX];
|
|
825
|
+
|
|
826
|
+
if (max && max !== Infinity) {
|
|
827
|
+
if (extras) {
|
|
828
|
+
str += ',';
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
str += '\n max: ' + util.inspect(max, opts);
|
|
832
|
+
extras = true;
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
var maxAge = this[MAX_AGE];
|
|
836
|
+
|
|
837
|
+
if (maxAge) {
|
|
838
|
+
if (extras) {
|
|
839
|
+
str += ',';
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
str += '\n maxAge: ' + util.inspect(maxAge, opts);
|
|
843
|
+
extras = true;
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
var lc = this[LENGTH_CALCULATOR];
|
|
847
|
+
|
|
848
|
+
if (lc && lc !== naiveLength) {
|
|
849
|
+
if (extras) {
|
|
850
|
+
str += ',';
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
str += '\n length: ' + util.inspect(this[LENGTH], opts);
|
|
854
|
+
extras = true;
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
var didFirst = false;
|
|
858
|
+
this[LRU_LIST].forEach(function (item) {
|
|
859
|
+
if (didFirst) {
|
|
860
|
+
str += ',\n ';
|
|
861
|
+
} else {
|
|
862
|
+
if (extras) {
|
|
863
|
+
str += ',\n';
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
didFirst = true;
|
|
867
|
+
str += '\n ';
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
var key = util.inspect(item.key).split('\n').join('\n ');
|
|
871
|
+
var val = {
|
|
872
|
+
value: item.value
|
|
873
|
+
};
|
|
874
|
+
|
|
875
|
+
if (item.maxAge !== maxAge) {
|
|
876
|
+
val.maxAge = item.maxAge;
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
if (lc !== naiveLength) {
|
|
880
|
+
val.length = item.length;
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
if (isStale(this, item)) {
|
|
884
|
+
val.stale = true;
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
val = util.inspect(val, opts).split('\n').join('\n ');
|
|
888
|
+
str += key + ' => ' + val;
|
|
889
|
+
});
|
|
890
|
+
|
|
891
|
+
if (didFirst || extras) {
|
|
892
|
+
str += '\n';
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
str += '}';
|
|
896
|
+
return str;
|
|
897
|
+
};
|
|
898
|
+
|
|
899
|
+
LRUCache.prototype.set = function (key, value, maxAge) {
|
|
900
|
+
maxAge = maxAge || this[MAX_AGE];
|
|
901
|
+
var now = maxAge ? Date.now() : 0;
|
|
902
|
+
var len = this[LENGTH_CALCULATOR](value, key);
|
|
903
|
+
|
|
904
|
+
if (this[CACHE].has(key)) {
|
|
905
|
+
if (len > this[MAX]) {
|
|
906
|
+
del(this, this[CACHE].get(key));
|
|
907
|
+
return false;
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
var node = this[CACHE].get(key);
|
|
911
|
+
var item = node.value; // dispose of the old one before overwriting
|
|
912
|
+
// split out into 2 ifs for better coverage tracking
|
|
913
|
+
|
|
914
|
+
if (this[DISPOSE]) {
|
|
915
|
+
if (!this[NO_DISPOSE_ON_SET]) {
|
|
916
|
+
this[DISPOSE](key, item.value);
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
item.now = now;
|
|
921
|
+
item.maxAge = maxAge;
|
|
922
|
+
item.value = value;
|
|
923
|
+
this[LENGTH] += len - item.length;
|
|
924
|
+
item.length = len;
|
|
925
|
+
this.get(key);
|
|
926
|
+
trim(this);
|
|
927
|
+
return true;
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
var hit = new Entry(key, value, len, now, maxAge); // oversized objects fall out of cache automatically.
|
|
931
|
+
|
|
932
|
+
if (hit.length > this[MAX]) {
|
|
933
|
+
if (this[DISPOSE]) {
|
|
934
|
+
this[DISPOSE](key, value);
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
return false;
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
this[LENGTH] += hit.length;
|
|
941
|
+
this[LRU_LIST].unshift(hit);
|
|
942
|
+
this[CACHE].set(key, this[LRU_LIST].head);
|
|
943
|
+
trim(this);
|
|
944
|
+
return true;
|
|
945
|
+
};
|
|
946
|
+
|
|
947
|
+
LRUCache.prototype.has = function (key) {
|
|
948
|
+
if (!this[CACHE].has(key)) return false;
|
|
949
|
+
var hit = this[CACHE].get(key).value;
|
|
950
|
+
|
|
951
|
+
if (isStale(this, hit)) {
|
|
952
|
+
return false;
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
return true;
|
|
956
|
+
};
|
|
957
|
+
|
|
958
|
+
LRUCache.prototype.get = function (key) {
|
|
959
|
+
return get(this, key, true);
|
|
960
|
+
};
|
|
961
|
+
|
|
962
|
+
LRUCache.prototype.peek = function (key) {
|
|
963
|
+
return get(this, key, false);
|
|
964
|
+
};
|
|
965
|
+
|
|
966
|
+
LRUCache.prototype.pop = function () {
|
|
967
|
+
var node = this[LRU_LIST].tail;
|
|
968
|
+
if (!node) return null;
|
|
969
|
+
del(this, node);
|
|
970
|
+
return node.value;
|
|
971
|
+
};
|
|
972
|
+
|
|
973
|
+
LRUCache.prototype.del = function (key) {
|
|
974
|
+
del(this, this[CACHE].get(key));
|
|
975
|
+
};
|
|
976
|
+
|
|
977
|
+
LRUCache.prototype.load = function (arr) {
|
|
978
|
+
// reset the cache
|
|
979
|
+
this.reset();
|
|
980
|
+
var now = Date.now(); // A previous serialized cache has the most recent items first
|
|
981
|
+
|
|
982
|
+
for (var l = arr.length - 1; l >= 0; l--) {
|
|
983
|
+
var hit = arr[l];
|
|
984
|
+
var expiresAt = hit.e || 0;
|
|
985
|
+
|
|
986
|
+
if (expiresAt === 0) {
|
|
987
|
+
// the item was created without expiration in a non aged cache
|
|
988
|
+
this.set(hit.k, hit.v);
|
|
989
|
+
} else {
|
|
990
|
+
var maxAge = expiresAt - now; // dont add already expired items
|
|
991
|
+
|
|
992
|
+
if (maxAge > 0) {
|
|
993
|
+
this.set(hit.k, hit.v, maxAge);
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
};
|
|
998
|
+
|
|
999
|
+
LRUCache.prototype.prune = function () {
|
|
1000
|
+
var self = this;
|
|
1001
|
+
this[CACHE].forEach(function (value, key) {
|
|
1002
|
+
get(self, key, false);
|
|
1003
|
+
});
|
|
1004
|
+
};
|
|
1005
|
+
|
|
1006
|
+
function get(self, key, doUse) {
|
|
1007
|
+
var node = self[CACHE].get(key);
|
|
1008
|
+
|
|
1009
|
+
if (node) {
|
|
1010
|
+
var hit = node.value;
|
|
1011
|
+
|
|
1012
|
+
if (isStale(self, hit)) {
|
|
1013
|
+
del(self, node);
|
|
1014
|
+
if (!self[ALLOW_STALE]) hit = undefined;
|
|
1015
|
+
} else {
|
|
1016
|
+
if (doUse) {
|
|
1017
|
+
self[LRU_LIST].unshiftNode(node);
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
if (hit) hit = hit.value;
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
return hit;
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
function isStale(self, hit) {
|
|
1028
|
+
if (!hit || !hit.maxAge && !self[MAX_AGE]) {
|
|
1029
|
+
return false;
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
var stale = false;
|
|
1033
|
+
var diff = Date.now() - hit.now;
|
|
1034
|
+
|
|
1035
|
+
if (hit.maxAge) {
|
|
1036
|
+
stale = diff > hit.maxAge;
|
|
1037
|
+
} else {
|
|
1038
|
+
stale = self[MAX_AGE] && diff > self[MAX_AGE];
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
return stale;
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
function trim(self) {
|
|
1045
|
+
if (self[LENGTH] > self[MAX]) {
|
|
1046
|
+
for (var walker = self[LRU_LIST].tail; self[LENGTH] > self[MAX] && walker !== null;) {
|
|
1047
|
+
// We know that we're about to delete this one, and also
|
|
1048
|
+
// what the next least recently used key will be, so just
|
|
1049
|
+
// go ahead and set it now.
|
|
1050
|
+
var prev = walker.prev;
|
|
1051
|
+
del(self, walker);
|
|
1052
|
+
walker = prev;
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
function del(self, node) {
|
|
1058
|
+
if (node) {
|
|
1059
|
+
var hit = node.value;
|
|
1060
|
+
|
|
1061
|
+
if (self[DISPOSE]) {
|
|
1062
|
+
self[DISPOSE](hit.key, hit.value);
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
self[LENGTH] -= hit.length;
|
|
1066
|
+
self[CACHE]["delete"](hit.key);
|
|
1067
|
+
self[LRU_LIST].removeNode(node);
|
|
1068
|
+
}
|
|
1069
|
+
} // classy, since V8 prefers predictable objects.
|
|
1070
|
+
|
|
1071
|
+
|
|
1072
|
+
function Entry(key, value, length, now, maxAge) {
|
|
1073
|
+
this.key = key;
|
|
1074
|
+
this.value = value;
|
|
1075
|
+
this.length = length;
|
|
1076
|
+
this.now = now;
|
|
1077
|
+
this.maxAge = maxAge || 0;
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
var windows;
|
|
1081
|
+
var hasRequiredWindows;
|
|
1082
|
+
|
|
1083
|
+
function requireWindows() {
|
|
1084
|
+
if (hasRequiredWindows) return windows;
|
|
1085
|
+
hasRequiredWindows = 1;
|
|
1086
|
+
windows = isexe;
|
|
1087
|
+
isexe.sync = sync;
|
|
1088
|
+
var fs = require$$0__default["default"];
|
|
1089
|
+
|
|
1090
|
+
function checkPathExt(path, options) {
|
|
1091
|
+
var pathext = options.pathExt !== undefined ? options.pathExt : process.env.PATHEXT;
|
|
1092
|
+
|
|
1093
|
+
if (!pathext) {
|
|
1094
|
+
return true;
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
pathext = pathext.split(';');
|
|
1098
|
+
|
|
1099
|
+
if (pathext.indexOf('') !== -1) {
|
|
1100
|
+
return true;
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
for (var i = 0; i < pathext.length; i++) {
|
|
1104
|
+
var p = pathext[i].toLowerCase();
|
|
1105
|
+
|
|
1106
|
+
if (p && path.substr(-p.length).toLowerCase() === p) {
|
|
1107
|
+
return true;
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
return false;
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
function checkStat(stat, path, options) {
|
|
1115
|
+
if (!stat.isSymbolicLink() && !stat.isFile()) {
|
|
1116
|
+
return false;
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1119
|
+
return checkPathExt(path, options);
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
function isexe(path, options, cb) {
|
|
1123
|
+
fs.stat(path, function (er, stat) {
|
|
1124
|
+
cb(er, er ? false : checkStat(stat, path, options));
|
|
1125
|
+
});
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
function sync(path, options) {
|
|
1129
|
+
return checkStat(fs.statSync(path), path, options);
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
return windows;
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
var mode;
|
|
1136
|
+
var hasRequiredMode;
|
|
1137
|
+
|
|
1138
|
+
function requireMode() {
|
|
1139
|
+
if (hasRequiredMode) return mode;
|
|
1140
|
+
hasRequiredMode = 1;
|
|
1141
|
+
mode = isexe;
|
|
1142
|
+
isexe.sync = sync;
|
|
1143
|
+
var fs = require$$0__default["default"];
|
|
1144
|
+
|
|
1145
|
+
function isexe(path, options, cb) {
|
|
1146
|
+
fs.stat(path, function (er, stat) {
|
|
1147
|
+
cb(er, er ? false : checkStat(stat, options));
|
|
1148
|
+
});
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
function sync(path, options) {
|
|
1152
|
+
return checkStat(fs.statSync(path), options);
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
function checkStat(stat, options) {
|
|
1156
|
+
return stat.isFile() && checkMode(stat, options);
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
function checkMode(stat, options) {
|
|
1160
|
+
var mod = stat.mode;
|
|
1161
|
+
var uid = stat.uid;
|
|
1162
|
+
var gid = stat.gid;
|
|
1163
|
+
var myUid = options.uid !== undefined ? options.uid : process.getuid && process.getuid();
|
|
1164
|
+
var myGid = options.gid !== undefined ? options.gid : process.getgid && process.getgid();
|
|
1165
|
+
var u = parseInt('100', 8);
|
|
1166
|
+
var g = parseInt('010', 8);
|
|
1167
|
+
var o = parseInt('001', 8);
|
|
1168
|
+
var ug = u | g;
|
|
1169
|
+
var ret = mod & o || mod & g && gid === myGid || mod & u && uid === myUid || mod & ug && myUid === 0;
|
|
1170
|
+
return ret;
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
return mode;
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
var core;
|
|
1177
|
+
|
|
1178
|
+
if (process.platform === 'win32' || commonjsGlobal.TESTING_WINDOWS) {
|
|
1179
|
+
core = requireWindows();
|
|
1180
|
+
} else {
|
|
1181
|
+
core = requireMode();
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
var isexe_1 = isexe$1;
|
|
1185
|
+
isexe$1.sync = sync$1;
|
|
1186
|
+
|
|
1187
|
+
function isexe$1(path, options, cb) {
|
|
1188
|
+
if (typeof options === 'function') {
|
|
1189
|
+
cb = options;
|
|
1190
|
+
options = {};
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
if (!cb) {
|
|
1194
|
+
if (typeof Promise !== 'function') {
|
|
1195
|
+
throw new TypeError('callback not provided');
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
return new Promise(function (resolve, reject) {
|
|
1199
|
+
isexe$1(path, options || {}, function (er, is) {
|
|
1200
|
+
if (er) {
|
|
1201
|
+
reject(er);
|
|
1202
|
+
} else {
|
|
1203
|
+
resolve(is);
|
|
1204
|
+
}
|
|
1205
|
+
});
|
|
1206
|
+
});
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
core(path, options || {}, function (er, is) {
|
|
1210
|
+
// ignore EACCES because that just means we aren't allowed to run it
|
|
1211
|
+
if (er) {
|
|
1212
|
+
if (er.code === 'EACCES' || options && options.ignoreErrors) {
|
|
1213
|
+
er = null;
|
|
1214
|
+
is = false;
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
cb(er, is);
|
|
1219
|
+
});
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
function sync$1(path, options) {
|
|
1223
|
+
// my kingdom for a filtered catch
|
|
1224
|
+
try {
|
|
1225
|
+
return core.sync(path, options || {});
|
|
1226
|
+
} catch (er) {
|
|
1227
|
+
if (options && options.ignoreErrors || er.code === 'EACCES') {
|
|
1228
|
+
return false;
|
|
1229
|
+
} else {
|
|
1230
|
+
throw er;
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
var which_1 = which$1;
|
|
1236
|
+
which$1.sync = whichSync;
|
|
1237
|
+
var isWindows = process.platform === 'win32' || process.env.OSTYPE === 'cygwin' || process.env.OSTYPE === 'msys';
|
|
1238
|
+
var path$1 = require$$0__default$1["default"];
|
|
1239
|
+
var COLON = isWindows ? ';' : ':';
|
|
1240
|
+
var isexe = isexe_1;
|
|
1241
|
+
|
|
1242
|
+
function getNotFoundError(cmd) {
|
|
1243
|
+
var er = new Error('not found: ' + cmd);
|
|
1244
|
+
er.code = 'ENOENT';
|
|
1245
|
+
return er;
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1248
|
+
function getPathInfo(cmd, opt) {
|
|
1249
|
+
var colon = opt.colon || COLON;
|
|
1250
|
+
var pathEnv = opt.path || process.env.PATH || '';
|
|
1251
|
+
var pathExt = [''];
|
|
1252
|
+
pathEnv = pathEnv.split(colon);
|
|
1253
|
+
var pathExtExe = '';
|
|
1254
|
+
|
|
1255
|
+
if (isWindows) {
|
|
1256
|
+
pathEnv.unshift(process.cwd());
|
|
1257
|
+
pathExtExe = opt.pathExt || process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM';
|
|
1258
|
+
pathExt = pathExtExe.split(colon); // Always test the cmd itself first. isexe will check to make sure
|
|
1259
|
+
// it's found in the pathExt set.
|
|
1260
|
+
|
|
1261
|
+
if (cmd.indexOf('.') !== -1 && pathExt[0] !== '') pathExt.unshift('');
|
|
1262
|
+
} // If it has a slash, then we don't bother searching the pathenv.
|
|
1263
|
+
// just check the file itself, and that's it.
|
|
1264
|
+
|
|
1265
|
+
|
|
1266
|
+
if (cmd.match(/\//) || isWindows && cmd.match(/\\/)) pathEnv = [''];
|
|
1267
|
+
return {
|
|
1268
|
+
env: pathEnv,
|
|
1269
|
+
ext: pathExt,
|
|
1270
|
+
extExe: pathExtExe
|
|
1271
|
+
};
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
function which$1(cmd, opt, cb) {
|
|
1275
|
+
if (typeof opt === 'function') {
|
|
1276
|
+
cb = opt;
|
|
1277
|
+
opt = {};
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
var info = getPathInfo(cmd, opt);
|
|
1281
|
+
var pathEnv = info.env;
|
|
1282
|
+
var pathExt = info.ext;
|
|
1283
|
+
var pathExtExe = info.extExe;
|
|
1284
|
+
var found = [];
|
|
1285
|
+
|
|
1286
|
+
(function F(i, l) {
|
|
1287
|
+
if (i === l) {
|
|
1288
|
+
if (opt.all && found.length) return cb(null, found);else return cb(getNotFoundError(cmd));
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
var pathPart = pathEnv[i];
|
|
1292
|
+
if (pathPart.charAt(0) === '"' && pathPart.slice(-1) === '"') pathPart = pathPart.slice(1, -1);
|
|
1293
|
+
var p = path$1.join(pathPart, cmd);
|
|
1294
|
+
|
|
1295
|
+
if (!pathPart && /^\.[\\\/]/.test(cmd)) {
|
|
1296
|
+
p = cmd.slice(0, 2) + p;
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1299
|
+
(function E(ii, ll) {
|
|
1300
|
+
if (ii === ll) return F(i + 1, l);
|
|
1301
|
+
var ext = pathExt[ii];
|
|
1302
|
+
isexe(p + ext, {
|
|
1303
|
+
pathExt: pathExtExe
|
|
1304
|
+
}, function (er, is) {
|
|
1305
|
+
if (!er && is) {
|
|
1306
|
+
if (opt.all) found.push(p + ext);else return cb(null, p + ext);
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
return E(ii + 1, ll);
|
|
1310
|
+
});
|
|
1311
|
+
})(0, pathExt.length);
|
|
1312
|
+
})(0, pathEnv.length);
|
|
1313
|
+
}
|
|
1314
|
+
|
|
1315
|
+
function whichSync(cmd, opt) {
|
|
1316
|
+
opt = opt || {};
|
|
1317
|
+
var info = getPathInfo(cmd, opt);
|
|
1318
|
+
var pathEnv = info.env;
|
|
1319
|
+
var pathExt = info.ext;
|
|
1320
|
+
var pathExtExe = info.extExe;
|
|
1321
|
+
var found = [];
|
|
1322
|
+
|
|
1323
|
+
for (var i = 0, l = pathEnv.length; i < l; i++) {
|
|
1324
|
+
var pathPart = pathEnv[i];
|
|
1325
|
+
if (pathPart.charAt(0) === '"' && pathPart.slice(-1) === '"') pathPart = pathPart.slice(1, -1);
|
|
1326
|
+
var p = path$1.join(pathPart, cmd);
|
|
1327
|
+
|
|
1328
|
+
if (!pathPart && /^\.[\\\/]/.test(cmd)) {
|
|
1329
|
+
p = cmd.slice(0, 2) + p;
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
for (var j = 0, ll = pathExt.length; j < ll; j++) {
|
|
1333
|
+
var cur = p + pathExt[j];
|
|
1334
|
+
var is;
|
|
1335
|
+
|
|
1336
|
+
try {
|
|
1337
|
+
is = isexe.sync(cur, {
|
|
1338
|
+
pathExt: pathExtExe
|
|
1339
|
+
});
|
|
1340
|
+
|
|
1341
|
+
if (is) {
|
|
1342
|
+
if (opt.all) found.push(cur);else return cur;
|
|
1343
|
+
}
|
|
1344
|
+
} catch (ex) {}
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
if (opt.all && found.length) return found;
|
|
1349
|
+
if (opt.nothrow) return null;
|
|
1350
|
+
throw getNotFoundError(cmd);
|
|
1351
|
+
}
|
|
1352
|
+
|
|
1353
|
+
var path = require$$0__default$1["default"];
|
|
1354
|
+
var which = which_1;
|
|
1355
|
+
var LRU$1 = lruCache;
|
|
1356
|
+
var commandCache = new LRU$1({
|
|
1357
|
+
max: 50,
|
|
1358
|
+
maxAge: 30 * 1000
|
|
1359
|
+
}); // Cache just for 30sec
|
|
1360
|
+
|
|
1361
|
+
function resolveCommand$2(command, noExtension) {
|
|
1362
|
+
var resolved;
|
|
1363
|
+
noExtension = !!noExtension;
|
|
1364
|
+
resolved = commandCache.get(command + '!' + noExtension); // Check if its resolved in the cache
|
|
1365
|
+
|
|
1366
|
+
if (commandCache.has(command)) {
|
|
1367
|
+
return commandCache.get(command);
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
try {
|
|
1371
|
+
resolved = !noExtension ? which.sync(command) : which.sync(command, {
|
|
1372
|
+
pathExt: path.delimiter + (process.env.PATHEXT || '')
|
|
1373
|
+
});
|
|
1374
|
+
} catch (e) {
|
|
1375
|
+
/* empty */
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
commandCache.set(command + '!' + noExtension, resolved);
|
|
1379
|
+
return resolved;
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
var resolveCommand_1 = resolveCommand$2;
|
|
1383
|
+
var fs = require$$0__default["default"];
|
|
1384
|
+
var LRU = lruCache;
|
|
1385
|
+
var resolveCommand$1 = resolveCommand_1;
|
|
1386
|
+
var isWin$1 = process.platform === 'win32';
|
|
1387
|
+
var shebangCache = new LRU({
|
|
1388
|
+
max: 50,
|
|
1389
|
+
maxAge: 30 * 1000
|
|
1390
|
+
}); // Cache just for 30sec
|
|
1391
|
+
|
|
1392
|
+
function readShebang(command) {
|
|
1393
|
+
var buffer;
|
|
1394
|
+
var fd;
|
|
1395
|
+
var match;
|
|
1396
|
+
var shebang; // Check if it is in the cache first
|
|
1397
|
+
|
|
1398
|
+
if (shebangCache.has(command)) {
|
|
1399
|
+
return shebangCache.get(command);
|
|
1400
|
+
} // Read the first 150 bytes from the file
|
|
1401
|
+
|
|
1402
|
+
|
|
1403
|
+
buffer = new Buffer(150);
|
|
1404
|
+
|
|
1405
|
+
try {
|
|
1406
|
+
fd = fs.openSync(command, 'r');
|
|
1407
|
+
fs.readSync(fd, buffer, 0, 150, 0);
|
|
1408
|
+
fs.closeSync(fd);
|
|
1409
|
+
} catch (e) {
|
|
1410
|
+
/* empty */
|
|
1411
|
+
} // Check if it is a shebang
|
|
1412
|
+
|
|
1413
|
+
|
|
1414
|
+
match = buffer.toString().trim().match(/#!(.+)/i);
|
|
1415
|
+
|
|
1416
|
+
if (match) {
|
|
1417
|
+
shebang = match[1].replace(/\/usr\/bin\/env\s+/i, ''); // Remove /usr/bin/env
|
|
1418
|
+
} // Store the shebang in the cache
|
|
1419
|
+
|
|
1420
|
+
|
|
1421
|
+
shebangCache.set(command, shebang);
|
|
1422
|
+
return shebang;
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
function escapeArg(arg, quote) {
|
|
1426
|
+
// Convert to string
|
|
1427
|
+
arg = '' + arg; // If we are not going to quote the argument,
|
|
1428
|
+
// escape shell metacharacters, including double and single quotes:
|
|
1429
|
+
|
|
1430
|
+
if (!quote) {
|
|
1431
|
+
arg = arg.replace(/([\(\)%!\^<>&|;,"'\s])/g, '^$1');
|
|
1432
|
+
} else {
|
|
1433
|
+
// Sequence of backslashes followed by a double quote:
|
|
1434
|
+
// double up all the backslashes and escape the double quote
|
|
1435
|
+
arg = arg.replace(/(\\*)"/g, '$1$1\\"'); // Sequence of backslashes followed by the end of the string
|
|
1436
|
+
// (which will become a double quote later):
|
|
1437
|
+
// double up all the backslashes
|
|
1438
|
+
|
|
1439
|
+
arg = arg.replace(/(\\*)$/, '$1$1'); // All other backslashes occur literally
|
|
1440
|
+
// Quote the whole thing:
|
|
1441
|
+
|
|
1442
|
+
arg = '"' + arg + '"';
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1445
|
+
return arg;
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1448
|
+
function escapeCommand(command) {
|
|
1449
|
+
// Do not escape if this command is not dangerous..
|
|
1450
|
+
// We do this so that commands like "echo" or "ifconfig" work
|
|
1451
|
+
// Quoting them, will make them unaccessible
|
|
1452
|
+
return /^[a-z0-9_-]+$/i.test(command) ? command : escapeArg(command, true);
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
function parse$1(command, args, options) {
|
|
1456
|
+
var shebang;
|
|
1457
|
+
var applyQuotes;
|
|
1458
|
+
var file;
|
|
1459
|
+
var original; // Normalize arguments, similar to nodejs
|
|
1460
|
+
|
|
1461
|
+
if (args && !Array.isArray(args)) {
|
|
1462
|
+
options = args;
|
|
1463
|
+
args = null;
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1466
|
+
args = args ? args.slice(0) : []; // Clone array to avoid changing the original
|
|
1467
|
+
|
|
1468
|
+
options = options || {};
|
|
1469
|
+
original = command;
|
|
1470
|
+
|
|
1471
|
+
if (isWin$1) {
|
|
1472
|
+
// Detect & add support for shebangs
|
|
1473
|
+
file = resolveCommand$1(command);
|
|
1474
|
+
file = file || resolveCommand$1(command, true);
|
|
1475
|
+
shebang = file && readShebang(file);
|
|
1476
|
+
|
|
1477
|
+
if (shebang) {
|
|
1478
|
+
args.unshift(file);
|
|
1479
|
+
command = shebang;
|
|
1480
|
+
} // Escape command & arguments
|
|
1481
|
+
|
|
1482
|
+
|
|
1483
|
+
applyQuotes = command !== 'echo'; // Do not quote arguments for the special "echo" command
|
|
1484
|
+
|
|
1485
|
+
command = escapeCommand(command);
|
|
1486
|
+
args = args.map(function (arg) {
|
|
1487
|
+
return escapeArg(arg, applyQuotes);
|
|
1488
|
+
}); // Use cmd.exe
|
|
1489
|
+
|
|
1490
|
+
args = ['/s', '/c', '"' + command + (args.length ? ' ' + args.join(' ') : '') + '"'];
|
|
1491
|
+
command = process.env.comspec || 'cmd.exe'; // Tell node's spawn that the arguments are already escaped
|
|
1492
|
+
|
|
1493
|
+
options.windowsVerbatimArguments = true;
|
|
1494
|
+
}
|
|
1495
|
+
|
|
1496
|
+
return {
|
|
1497
|
+
command: command,
|
|
1498
|
+
args: args,
|
|
1499
|
+
options: options,
|
|
1500
|
+
file: file,
|
|
1501
|
+
original: original
|
|
1502
|
+
};
|
|
1503
|
+
}
|
|
1504
|
+
|
|
1505
|
+
var parse_1 = parse$1;
|
|
1506
|
+
var enoent$1 = {};
|
|
1507
|
+
var isWin = process.platform === 'win32';
|
|
1508
|
+
var resolveCommand = resolveCommand_1;
|
|
1509
|
+
var isNode10 = process.version.indexOf('v0.10.') === 0;
|
|
1510
|
+
|
|
1511
|
+
function notFoundError(command, syscall) {
|
|
1512
|
+
var err;
|
|
1513
|
+
err = new Error(syscall + ' ' + command + ' ENOENT');
|
|
1514
|
+
err.code = err.errno = 'ENOENT';
|
|
1515
|
+
err.syscall = syscall + ' ' + command;
|
|
1516
|
+
return err;
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1519
|
+
function hookChildProcess(cp, parsed) {
|
|
1520
|
+
var originalEmit;
|
|
1521
|
+
|
|
1522
|
+
if (!isWin) {
|
|
1523
|
+
return;
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
originalEmit = cp.emit;
|
|
1527
|
+
|
|
1528
|
+
cp.emit = function (name, arg1) {
|
|
1529
|
+
var err; // If emitting "exit" event and exit code is 1, we need to check if
|
|
1530
|
+
// the command exists and emit an "error" instead
|
|
1531
|
+
// See: https://github.com/IndigoUnited/node-cross-spawn/issues/16
|
|
1532
|
+
|
|
1533
|
+
if (name === 'exit') {
|
|
1534
|
+
err = verifyENOENT(arg1, parsed);
|
|
1535
|
+
|
|
1536
|
+
if (err) {
|
|
1537
|
+
return originalEmit.call(cp, 'error', err);
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
|
|
1541
|
+
return originalEmit.apply(cp, arguments);
|
|
1542
|
+
};
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
function verifyENOENT(status, parsed) {
|
|
1546
|
+
if (isWin && status === 1 && !parsed.file) {
|
|
1547
|
+
return notFoundError(parsed.original, 'spawn');
|
|
1548
|
+
}
|
|
1549
|
+
|
|
1550
|
+
return null;
|
|
1551
|
+
}
|
|
1552
|
+
|
|
1553
|
+
function verifyENOENTSync(status, parsed) {
|
|
1554
|
+
if (isWin && status === 1 && !parsed.file) {
|
|
1555
|
+
return notFoundError(parsed.original, 'spawnSync');
|
|
1556
|
+
} // If we are in node 10, then we are using spawn-sync; if it exited
|
|
1557
|
+
// with -1 it probably means that the command does not exist
|
|
1558
|
+
|
|
1559
|
+
|
|
1560
|
+
if (isNode10 && status === -1) {
|
|
1561
|
+
parsed.file = isWin ? parsed.file : resolveCommand(parsed.original);
|
|
1562
|
+
|
|
1563
|
+
if (!parsed.file) {
|
|
1564
|
+
return notFoundError(parsed.original, 'spawnSync');
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
|
|
1568
|
+
return null;
|
|
1569
|
+
}
|
|
1570
|
+
|
|
1571
|
+
enoent$1.hookChildProcess = hookChildProcess;
|
|
1572
|
+
enoent$1.verifyENOENT = verifyENOENT;
|
|
1573
|
+
enoent$1.verifyENOENTSync = verifyENOENTSync;
|
|
1574
|
+
enoent$1.notFoundError = notFoundError;
|
|
1575
|
+
var cp = require$$0__default$2["default"];
|
|
1576
|
+
var parse = parse_1;
|
|
1577
|
+
var enoent = enoent$1;
|
|
1578
|
+
var cpSpawnSync = cp.spawnSync;
|
|
1579
|
+
|
|
1580
|
+
function spawn(command, args, options) {
|
|
1581
|
+
var parsed;
|
|
1582
|
+
var spawned; // Parse the arguments
|
|
1583
|
+
|
|
1584
|
+
parsed = parse(command, args, options); // Spawn the child process
|
|
1585
|
+
|
|
1586
|
+
spawned = cp.spawn(parsed.command, parsed.args, parsed.options); // Hook into child process "exit" event to emit an error if the command
|
|
1587
|
+
// does not exists, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16
|
|
1588
|
+
|
|
1589
|
+
enoent.hookChildProcess(spawned, parsed);
|
|
1590
|
+
return spawned;
|
|
1591
|
+
}
|
|
1592
|
+
|
|
1593
|
+
function spawnSync(command, args, options) {
|
|
1594
|
+
var parsed;
|
|
1595
|
+
var result;
|
|
1596
|
+
|
|
1597
|
+
if (!cpSpawnSync) {
|
|
1598
|
+
try {
|
|
1599
|
+
cpSpawnSync = require('../spawn-sync/spawn-sync'); // eslint-disable-line global-require
|
|
1600
|
+
} catch (ex) {
|
|
1601
|
+
throw new Error('In order to use spawnSync on node 0.10 or older, you must ' + 'install spawn-sync:\n\n' + ' npm install spawn-sync --save');
|
|
1602
|
+
}
|
|
1603
|
+
} // Parse the arguments
|
|
1604
|
+
|
|
1605
|
+
|
|
1606
|
+
parsed = parse(command, args, options); // Spawn the child process
|
|
1607
|
+
|
|
1608
|
+
result = cpSpawnSync(parsed.command, parsed.args, parsed.options); // Analyze if the command does not exists, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16
|
|
1609
|
+
|
|
1610
|
+
result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
|
|
1611
|
+
return result;
|
|
1612
|
+
}
|
|
1613
|
+
|
|
1614
|
+
crossSpawn.exports = spawn;
|
|
1615
|
+
var spawn_1 = crossSpawn.exports.spawn = spawn;
|
|
1616
|
+
var sync = crossSpawn.exports.sync = spawnSync;
|
|
1617
|
+
|
|
1618
|
+
var _parse = crossSpawn.exports._parse = parse;
|
|
1619
|
+
|
|
1620
|
+
var _enoent = crossSpawn.exports._enoent = enoent;
|
|
1621
|
+
|
|
1622
|
+
exports._enoent = _enoent;
|
|
1623
|
+
exports._parse = _parse;
|
|
1624
|
+
exports["default"] = crossSpawn.exports;
|
|
1625
|
+
exports.spawn = spawn_1;
|
|
1626
|
+
exports.sync = sync;
|