@builderbot/provider-venom 1.0.32-alpha.0 → 1.1.0

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/dist/index.cjs CHANGED
@@ -1,14 +1,20 @@
1
1
  'use strict';
2
2
 
3
3
  var bot = require('@builderbot/bot');
4
- var fs = require('fs');
4
+ var require$$0$3 = require('fs');
5
5
  var promises = require('fs/promises');
6
6
  var require$$1 = require('path');
7
7
  var os = require('os');
8
8
  var venom = require('venom-bot');
9
+ var require$$0$1 = require('constants');
10
+ var require$$0$2 = require('stream');
11
+ var require$$4 = require('util');
12
+ var require$$5 = require('assert');
9
13
  require('http');
10
14
  require('https');
11
15
 
16
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
17
+
12
18
  function getDefaultExportFromCjs (x) {
13
19
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
14
20
  }
@@ -10923,6 +10929,2452 @@ var mimeDb = require$$0;
10923
10929
 
10924
10930
  var mime = /*@__PURE__*/getDefaultExportFromCjs(mimeTypes);
10925
10931
 
10932
+ var fs$h = {};
10933
+
10934
+ var universalify$1 = {};
10935
+
10936
+ universalify$1.fromCallback = function (fn) {
10937
+ return Object.defineProperty(function (...args) {
10938
+ if (typeof args[args.length - 1] === 'function') fn.apply(this, args);
10939
+ else {
10940
+ return new Promise((resolve, reject) => {
10941
+ args.push((err, res) => (err != null) ? reject(err) : resolve(res));
10942
+ fn.apply(this, args);
10943
+ })
10944
+ }
10945
+ }, 'name', { value: fn.name })
10946
+ };
10947
+
10948
+ universalify$1.fromPromise = function (fn) {
10949
+ return Object.defineProperty(function (...args) {
10950
+ const cb = args[args.length - 1];
10951
+ if (typeof cb !== 'function') return fn.apply(this, args)
10952
+ else {
10953
+ args.pop();
10954
+ fn.apply(this, args).then(r => cb(null, r), cb);
10955
+ }
10956
+ }, 'name', { value: fn.name })
10957
+ };
10958
+
10959
+ var constants = require$$0$1;
10960
+
10961
+ var origCwd = process.cwd;
10962
+ var cwd = null;
10963
+
10964
+ var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform;
10965
+
10966
+ process.cwd = function() {
10967
+ if (!cwd)
10968
+ cwd = origCwd.call(process);
10969
+ return cwd
10970
+ };
10971
+ try {
10972
+ process.cwd();
10973
+ } catch (er) {}
10974
+
10975
+ // This check is needed until node.js 12 is required
10976
+ if (typeof process.chdir === 'function') {
10977
+ var chdir = process.chdir;
10978
+ process.chdir = function (d) {
10979
+ cwd = null;
10980
+ chdir.call(process, d);
10981
+ };
10982
+ if (Object.setPrototypeOf) Object.setPrototypeOf(process.chdir, chdir);
10983
+ }
10984
+
10985
+ var polyfills$1 = patch$1;
10986
+
10987
+ function patch$1 (fs) {
10988
+ // (re-)implement some things that are known busted or missing.
10989
+
10990
+ // lchmod, broken prior to 0.6.2
10991
+ // back-port the fix here.
10992
+ if (constants.hasOwnProperty('O_SYMLINK') &&
10993
+ process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
10994
+ patchLchmod(fs);
10995
+ }
10996
+
10997
+ // lutimes implementation, or no-op
10998
+ if (!fs.lutimes) {
10999
+ patchLutimes(fs);
11000
+ }
11001
+
11002
+ // https://github.com/isaacs/node-graceful-fs/issues/4
11003
+ // Chown should not fail on einval or eperm if non-root.
11004
+ // It should not fail on enosys ever, as this just indicates
11005
+ // that a fs doesn't support the intended operation.
11006
+
11007
+ fs.chown = chownFix(fs.chown);
11008
+ fs.fchown = chownFix(fs.fchown);
11009
+ fs.lchown = chownFix(fs.lchown);
11010
+
11011
+ fs.chmod = chmodFix(fs.chmod);
11012
+ fs.fchmod = chmodFix(fs.fchmod);
11013
+ fs.lchmod = chmodFix(fs.lchmod);
11014
+
11015
+ fs.chownSync = chownFixSync(fs.chownSync);
11016
+ fs.fchownSync = chownFixSync(fs.fchownSync);
11017
+ fs.lchownSync = chownFixSync(fs.lchownSync);
11018
+
11019
+ fs.chmodSync = chmodFixSync(fs.chmodSync);
11020
+ fs.fchmodSync = chmodFixSync(fs.fchmodSync);
11021
+ fs.lchmodSync = chmodFixSync(fs.lchmodSync);
11022
+
11023
+ fs.stat = statFix(fs.stat);
11024
+ fs.fstat = statFix(fs.fstat);
11025
+ fs.lstat = statFix(fs.lstat);
11026
+
11027
+ fs.statSync = statFixSync(fs.statSync);
11028
+ fs.fstatSync = statFixSync(fs.fstatSync);
11029
+ fs.lstatSync = statFixSync(fs.lstatSync);
11030
+
11031
+ // if lchmod/lchown do not exist, then make them no-ops
11032
+ if (fs.chmod && !fs.lchmod) {
11033
+ fs.lchmod = function (path, mode, cb) {
11034
+ if (cb) process.nextTick(cb);
11035
+ };
11036
+ fs.lchmodSync = function () {};
11037
+ }
11038
+ if (fs.chown && !fs.lchown) {
11039
+ fs.lchown = function (path, uid, gid, cb) {
11040
+ if (cb) process.nextTick(cb);
11041
+ };
11042
+ fs.lchownSync = function () {};
11043
+ }
11044
+
11045
+ // on Windows, A/V software can lock the directory, causing this
11046
+ // to fail with an EACCES or EPERM if the directory contains newly
11047
+ // created files. Try again on failure, for up to 60 seconds.
11048
+
11049
+ // Set the timeout this long because some Windows Anti-Virus, such as Parity
11050
+ // bit9, may lock files for up to a minute, causing npm package install
11051
+ // failures. Also, take care to yield the scheduler. Windows scheduling gives
11052
+ // CPU to a busy looping process, which can cause the program causing the lock
11053
+ // contention to be starved of CPU by node, so the contention doesn't resolve.
11054
+ if (platform === "win32") {
11055
+ fs.rename = typeof fs.rename !== 'function' ? fs.rename
11056
+ : (function (fs$rename) {
11057
+ function rename (from, to, cb) {
11058
+ var start = Date.now();
11059
+ var backoff = 0;
11060
+ fs$rename(from, to, function CB (er) {
11061
+ if (er
11062
+ && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY")
11063
+ && Date.now() - start < 60000) {
11064
+ setTimeout(function() {
11065
+ fs.stat(to, function (stater, st) {
11066
+ if (stater && stater.code === "ENOENT")
11067
+ fs$rename(from, to, CB);
11068
+ else
11069
+ cb(er);
11070
+ });
11071
+ }, backoff);
11072
+ if (backoff < 100)
11073
+ backoff += 10;
11074
+ return;
11075
+ }
11076
+ if (cb) cb(er);
11077
+ });
11078
+ }
11079
+ if (Object.setPrototypeOf) Object.setPrototypeOf(rename, fs$rename);
11080
+ return rename
11081
+ })(fs.rename);
11082
+ }
11083
+
11084
+ // if read() returns EAGAIN, then just try it again.
11085
+ fs.read = typeof fs.read !== 'function' ? fs.read
11086
+ : (function (fs$read) {
11087
+ function read (fd, buffer, offset, length, position, callback_) {
11088
+ var callback;
11089
+ if (callback_ && typeof callback_ === 'function') {
11090
+ var eagCounter = 0;
11091
+ callback = function (er, _, __) {
11092
+ if (er && er.code === 'EAGAIN' && eagCounter < 10) {
11093
+ eagCounter ++;
11094
+ return fs$read.call(fs, fd, buffer, offset, length, position, callback)
11095
+ }
11096
+ callback_.apply(this, arguments);
11097
+ };
11098
+ }
11099
+ return fs$read.call(fs, fd, buffer, offset, length, position, callback)
11100
+ }
11101
+
11102
+ // This ensures `util.promisify` works as it does for native `fs.read`.
11103
+ if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
11104
+ return read
11105
+ })(fs.read);
11106
+
11107
+ fs.readSync = typeof fs.readSync !== 'function' ? fs.readSync
11108
+ : (function (fs$readSync) { return function (fd, buffer, offset, length, position) {
11109
+ var eagCounter = 0;
11110
+ while (true) {
11111
+ try {
11112
+ return fs$readSync.call(fs, fd, buffer, offset, length, position)
11113
+ } catch (er) {
11114
+ if (er.code === 'EAGAIN' && eagCounter < 10) {
11115
+ eagCounter ++;
11116
+ continue
11117
+ }
11118
+ throw er
11119
+ }
11120
+ }
11121
+ }})(fs.readSync);
11122
+
11123
+ function patchLchmod (fs) {
11124
+ fs.lchmod = function (path, mode, callback) {
11125
+ fs.open( path
11126
+ , constants.O_WRONLY | constants.O_SYMLINK
11127
+ , mode
11128
+ , function (err, fd) {
11129
+ if (err) {
11130
+ if (callback) callback(err);
11131
+ return
11132
+ }
11133
+ // prefer to return the chmod error, if one occurs,
11134
+ // but still try to close, and report closing errors if they occur.
11135
+ fs.fchmod(fd, mode, function (err) {
11136
+ fs.close(fd, function(err2) {
11137
+ if (callback) callback(err || err2);
11138
+ });
11139
+ });
11140
+ });
11141
+ };
11142
+
11143
+ fs.lchmodSync = function (path, mode) {
11144
+ var fd = fs.openSync(path, constants.O_WRONLY | constants.O_SYMLINK, mode);
11145
+
11146
+ // prefer to return the chmod error, if one occurs,
11147
+ // but still try to close, and report closing errors if they occur.
11148
+ var threw = true;
11149
+ var ret;
11150
+ try {
11151
+ ret = fs.fchmodSync(fd, mode);
11152
+ threw = false;
11153
+ } finally {
11154
+ if (threw) {
11155
+ try {
11156
+ fs.closeSync(fd);
11157
+ } catch (er) {}
11158
+ } else {
11159
+ fs.closeSync(fd);
11160
+ }
11161
+ }
11162
+ return ret
11163
+ };
11164
+ }
11165
+
11166
+ function patchLutimes (fs) {
11167
+ if (constants.hasOwnProperty("O_SYMLINK") && fs.futimes) {
11168
+ fs.lutimes = function (path, at, mt, cb) {
11169
+ fs.open(path, constants.O_SYMLINK, function (er, fd) {
11170
+ if (er) {
11171
+ if (cb) cb(er);
11172
+ return
11173
+ }
11174
+ fs.futimes(fd, at, mt, function (er) {
11175
+ fs.close(fd, function (er2) {
11176
+ if (cb) cb(er || er2);
11177
+ });
11178
+ });
11179
+ });
11180
+ };
11181
+
11182
+ fs.lutimesSync = function (path, at, mt) {
11183
+ var fd = fs.openSync(path, constants.O_SYMLINK);
11184
+ var ret;
11185
+ var threw = true;
11186
+ try {
11187
+ ret = fs.futimesSync(fd, at, mt);
11188
+ threw = false;
11189
+ } finally {
11190
+ if (threw) {
11191
+ try {
11192
+ fs.closeSync(fd);
11193
+ } catch (er) {}
11194
+ } else {
11195
+ fs.closeSync(fd);
11196
+ }
11197
+ }
11198
+ return ret
11199
+ };
11200
+
11201
+ } else if (fs.futimes) {
11202
+ fs.lutimes = function (_a, _b, _c, cb) { if (cb) process.nextTick(cb); };
11203
+ fs.lutimesSync = function () {};
11204
+ }
11205
+ }
11206
+
11207
+ function chmodFix (orig) {
11208
+ if (!orig) return orig
11209
+ return function (target, mode, cb) {
11210
+ return orig.call(fs, target, mode, function (er) {
11211
+ if (chownErOk(er)) er = null;
11212
+ if (cb) cb.apply(this, arguments);
11213
+ })
11214
+ }
11215
+ }
11216
+
11217
+ function chmodFixSync (orig) {
11218
+ if (!orig) return orig
11219
+ return function (target, mode) {
11220
+ try {
11221
+ return orig.call(fs, target, mode)
11222
+ } catch (er) {
11223
+ if (!chownErOk(er)) throw er
11224
+ }
11225
+ }
11226
+ }
11227
+
11228
+
11229
+ function chownFix (orig) {
11230
+ if (!orig) return orig
11231
+ return function (target, uid, gid, cb) {
11232
+ return orig.call(fs, target, uid, gid, function (er) {
11233
+ if (chownErOk(er)) er = null;
11234
+ if (cb) cb.apply(this, arguments);
11235
+ })
11236
+ }
11237
+ }
11238
+
11239
+ function chownFixSync (orig) {
11240
+ if (!orig) return orig
11241
+ return function (target, uid, gid) {
11242
+ try {
11243
+ return orig.call(fs, target, uid, gid)
11244
+ } catch (er) {
11245
+ if (!chownErOk(er)) throw er
11246
+ }
11247
+ }
11248
+ }
11249
+
11250
+ function statFix (orig) {
11251
+ if (!orig) return orig
11252
+ // Older versions of Node erroneously returned signed integers for
11253
+ // uid + gid.
11254
+ return function (target, options, cb) {
11255
+ if (typeof options === 'function') {
11256
+ cb = options;
11257
+ options = null;
11258
+ }
11259
+ function callback (er, stats) {
11260
+ if (stats) {
11261
+ if (stats.uid < 0) stats.uid += 0x100000000;
11262
+ if (stats.gid < 0) stats.gid += 0x100000000;
11263
+ }
11264
+ if (cb) cb.apply(this, arguments);
11265
+ }
11266
+ return options ? orig.call(fs, target, options, callback)
11267
+ : orig.call(fs, target, callback)
11268
+ }
11269
+ }
11270
+
11271
+ function statFixSync (orig) {
11272
+ if (!orig) return orig
11273
+ // Older versions of Node erroneously returned signed integers for
11274
+ // uid + gid.
11275
+ return function (target, options) {
11276
+ var stats = options ? orig.call(fs, target, options)
11277
+ : orig.call(fs, target);
11278
+ if (stats) {
11279
+ if (stats.uid < 0) stats.uid += 0x100000000;
11280
+ if (stats.gid < 0) stats.gid += 0x100000000;
11281
+ }
11282
+ return stats;
11283
+ }
11284
+ }
11285
+
11286
+ // ENOSYS means that the fs doesn't support the op. Just ignore
11287
+ // that, because it doesn't matter.
11288
+ //
11289
+ // if there's no getuid, or if getuid() is something other
11290
+ // than 0, and the error is EINVAL or EPERM, then just ignore
11291
+ // it.
11292
+ //
11293
+ // This specific case is a silent failure in cp, install, tar,
11294
+ // and most other unix tools that manage permissions.
11295
+ //
11296
+ // When running as root, or if other types of errors are
11297
+ // encountered, then it's strict.
11298
+ function chownErOk (er) {
11299
+ if (!er)
11300
+ return true
11301
+
11302
+ if (er.code === "ENOSYS")
11303
+ return true
11304
+
11305
+ var nonroot = !process.getuid || process.getuid() !== 0;
11306
+ if (nonroot) {
11307
+ if (er.code === "EINVAL" || er.code === "EPERM")
11308
+ return true
11309
+ }
11310
+
11311
+ return false
11312
+ }
11313
+ }
11314
+
11315
+ var Stream = require$$0$2.Stream;
11316
+
11317
+ var legacyStreams = legacy$1;
11318
+
11319
+ function legacy$1 (fs) {
11320
+ return {
11321
+ ReadStream: ReadStream,
11322
+ WriteStream: WriteStream
11323
+ }
11324
+
11325
+ function ReadStream (path, options) {
11326
+ if (!(this instanceof ReadStream)) return new ReadStream(path, options);
11327
+
11328
+ Stream.call(this);
11329
+
11330
+ var self = this;
11331
+
11332
+ this.path = path;
11333
+ this.fd = null;
11334
+ this.readable = true;
11335
+ this.paused = false;
11336
+
11337
+ this.flags = 'r';
11338
+ this.mode = 438; /*=0666*/
11339
+ this.bufferSize = 64 * 1024;
11340
+
11341
+ options = options || {};
11342
+
11343
+ // Mixin options into this
11344
+ var keys = Object.keys(options);
11345
+ for (var index = 0, length = keys.length; index < length; index++) {
11346
+ var key = keys[index];
11347
+ this[key] = options[key];
11348
+ }
11349
+
11350
+ if (this.encoding) this.setEncoding(this.encoding);
11351
+
11352
+ if (this.start !== undefined) {
11353
+ if ('number' !== typeof this.start) {
11354
+ throw TypeError('start must be a Number');
11355
+ }
11356
+ if (this.end === undefined) {
11357
+ this.end = Infinity;
11358
+ } else if ('number' !== typeof this.end) {
11359
+ throw TypeError('end must be a Number');
11360
+ }
11361
+
11362
+ if (this.start > this.end) {
11363
+ throw new Error('start must be <= end');
11364
+ }
11365
+
11366
+ this.pos = this.start;
11367
+ }
11368
+
11369
+ if (this.fd !== null) {
11370
+ process.nextTick(function() {
11371
+ self._read();
11372
+ });
11373
+ return;
11374
+ }
11375
+
11376
+ fs.open(this.path, this.flags, this.mode, function (err, fd) {
11377
+ if (err) {
11378
+ self.emit('error', err);
11379
+ self.readable = false;
11380
+ return;
11381
+ }
11382
+
11383
+ self.fd = fd;
11384
+ self.emit('open', fd);
11385
+ self._read();
11386
+ });
11387
+ }
11388
+
11389
+ function WriteStream (path, options) {
11390
+ if (!(this instanceof WriteStream)) return new WriteStream(path, options);
11391
+
11392
+ Stream.call(this);
11393
+
11394
+ this.path = path;
11395
+ this.fd = null;
11396
+ this.writable = true;
11397
+
11398
+ this.flags = 'w';
11399
+ this.encoding = 'binary';
11400
+ this.mode = 438; /*=0666*/
11401
+ this.bytesWritten = 0;
11402
+
11403
+ options = options || {};
11404
+
11405
+ // Mixin options into this
11406
+ var keys = Object.keys(options);
11407
+ for (var index = 0, length = keys.length; index < length; index++) {
11408
+ var key = keys[index];
11409
+ this[key] = options[key];
11410
+ }
11411
+
11412
+ if (this.start !== undefined) {
11413
+ if ('number' !== typeof this.start) {
11414
+ throw TypeError('start must be a Number');
11415
+ }
11416
+ if (this.start < 0) {
11417
+ throw new Error('start must be >= zero');
11418
+ }
11419
+
11420
+ this.pos = this.start;
11421
+ }
11422
+
11423
+ this.busy = false;
11424
+ this._queue = [];
11425
+
11426
+ if (this.fd === null) {
11427
+ this._open = fs.open;
11428
+ this._queue.push([this._open, this.path, this.flags, this.mode, undefined]);
11429
+ this.flush();
11430
+ }
11431
+ }
11432
+ }
11433
+
11434
+ var clone_1 = clone$1;
11435
+
11436
+ var getPrototypeOf = Object.getPrototypeOf || function (obj) {
11437
+ return obj.__proto__
11438
+ };
11439
+
11440
+ function clone$1 (obj) {
11441
+ if (obj === null || typeof obj !== 'object')
11442
+ return obj
11443
+
11444
+ if (obj instanceof Object)
11445
+ var copy = { __proto__: getPrototypeOf(obj) };
11446
+ else
11447
+ var copy = Object.create(null);
11448
+
11449
+ Object.getOwnPropertyNames(obj).forEach(function (key) {
11450
+ Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key));
11451
+ });
11452
+
11453
+ return copy
11454
+ }
11455
+
11456
+ var fs$g = require$$0$3;
11457
+ var polyfills = polyfills$1;
11458
+ var legacy = legacyStreams;
11459
+ var clone = clone_1;
11460
+
11461
+ var util = require$$4;
11462
+
11463
+ /* istanbul ignore next - node 0.x polyfill */
11464
+ var gracefulQueue;
11465
+ var previousSymbol;
11466
+
11467
+ /* istanbul ignore else - node 0.x polyfill */
11468
+ if (typeof Symbol === 'function' && typeof Symbol.for === 'function') {
11469
+ gracefulQueue = Symbol.for('graceful-fs.queue');
11470
+ // This is used in testing by future versions
11471
+ previousSymbol = Symbol.for('graceful-fs.previous');
11472
+ } else {
11473
+ gracefulQueue = '___graceful-fs.queue';
11474
+ previousSymbol = '___graceful-fs.previous';
11475
+ }
11476
+
11477
+ function noop () {}
11478
+
11479
+ function publishQueue(context, queue) {
11480
+ Object.defineProperty(context, gracefulQueue, {
11481
+ get: function() {
11482
+ return queue
11483
+ }
11484
+ });
11485
+ }
11486
+
11487
+ var debug = noop;
11488
+ if (util.debuglog)
11489
+ debug = util.debuglog('gfs4');
11490
+ else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || ''))
11491
+ debug = function() {
11492
+ var m = util.format.apply(util, arguments);
11493
+ m = 'GFS4: ' + m.split(/\n/).join('\nGFS4: ');
11494
+ console.error(m);
11495
+ };
11496
+
11497
+ // Once time initialization
11498
+ if (!fs$g[gracefulQueue]) {
11499
+ // This queue can be shared by multiple loaded instances
11500
+ var queue = commonjsGlobal[gracefulQueue] || [];
11501
+ publishQueue(fs$g, queue);
11502
+
11503
+ // Patch fs.close/closeSync to shared queue version, because we need
11504
+ // to retry() whenever a close happens *anywhere* in the program.
11505
+ // This is essential when multiple graceful-fs instances are
11506
+ // in play at the same time.
11507
+ fs$g.close = (function (fs$close) {
11508
+ function close (fd, cb) {
11509
+ return fs$close.call(fs$g, fd, function (err) {
11510
+ // This function uses the graceful-fs shared queue
11511
+ if (!err) {
11512
+ resetQueue();
11513
+ }
11514
+
11515
+ if (typeof cb === 'function')
11516
+ cb.apply(this, arguments);
11517
+ })
11518
+ }
11519
+
11520
+ Object.defineProperty(close, previousSymbol, {
11521
+ value: fs$close
11522
+ });
11523
+ return close
11524
+ })(fs$g.close);
11525
+
11526
+ fs$g.closeSync = (function (fs$closeSync) {
11527
+ function closeSync (fd) {
11528
+ // This function uses the graceful-fs shared queue
11529
+ fs$closeSync.apply(fs$g, arguments);
11530
+ resetQueue();
11531
+ }
11532
+
11533
+ Object.defineProperty(closeSync, previousSymbol, {
11534
+ value: fs$closeSync
11535
+ });
11536
+ return closeSync
11537
+ })(fs$g.closeSync);
11538
+
11539
+ if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || '')) {
11540
+ process.on('exit', function() {
11541
+ debug(fs$g[gracefulQueue]);
11542
+ require$$5.equal(fs$g[gracefulQueue].length, 0);
11543
+ });
11544
+ }
11545
+ }
11546
+
11547
+ if (!commonjsGlobal[gracefulQueue]) {
11548
+ publishQueue(commonjsGlobal, fs$g[gracefulQueue]);
11549
+ }
11550
+
11551
+ var gracefulFs = patch(clone(fs$g));
11552
+ if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs$g.__patched) {
11553
+ gracefulFs = patch(fs$g);
11554
+ fs$g.__patched = true;
11555
+ }
11556
+
11557
+ function patch (fs) {
11558
+ // Everything that references the open() function needs to be in here
11559
+ polyfills(fs);
11560
+ fs.gracefulify = patch;
11561
+
11562
+ fs.createReadStream = createReadStream;
11563
+ fs.createWriteStream = createWriteStream;
11564
+ var fs$readFile = fs.readFile;
11565
+ fs.readFile = readFile;
11566
+ function readFile (path, options, cb) {
11567
+ if (typeof options === 'function')
11568
+ cb = options, options = null;
11569
+
11570
+ return go$readFile(path, options, cb)
11571
+
11572
+ function go$readFile (path, options, cb, startTime) {
11573
+ return fs$readFile(path, options, function (err) {
11574
+ if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
11575
+ enqueue([go$readFile, [path, options, cb], err, startTime || Date.now(), Date.now()]);
11576
+ else {
11577
+ if (typeof cb === 'function')
11578
+ cb.apply(this, arguments);
11579
+ }
11580
+ })
11581
+ }
11582
+ }
11583
+
11584
+ var fs$writeFile = fs.writeFile;
11585
+ fs.writeFile = writeFile;
11586
+ function writeFile (path, data, options, cb) {
11587
+ if (typeof options === 'function')
11588
+ cb = options, options = null;
11589
+
11590
+ return go$writeFile(path, data, options, cb)
11591
+
11592
+ function go$writeFile (path, data, options, cb, startTime) {
11593
+ return fs$writeFile(path, data, options, function (err) {
11594
+ if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
11595
+ enqueue([go$writeFile, [path, data, options, cb], err, startTime || Date.now(), Date.now()]);
11596
+ else {
11597
+ if (typeof cb === 'function')
11598
+ cb.apply(this, arguments);
11599
+ }
11600
+ })
11601
+ }
11602
+ }
11603
+
11604
+ var fs$appendFile = fs.appendFile;
11605
+ if (fs$appendFile)
11606
+ fs.appendFile = appendFile;
11607
+ function appendFile (path, data, options, cb) {
11608
+ if (typeof options === 'function')
11609
+ cb = options, options = null;
11610
+
11611
+ return go$appendFile(path, data, options, cb)
11612
+
11613
+ function go$appendFile (path, data, options, cb, startTime) {
11614
+ return fs$appendFile(path, data, options, function (err) {
11615
+ if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
11616
+ enqueue([go$appendFile, [path, data, options, cb], err, startTime || Date.now(), Date.now()]);
11617
+ else {
11618
+ if (typeof cb === 'function')
11619
+ cb.apply(this, arguments);
11620
+ }
11621
+ })
11622
+ }
11623
+ }
11624
+
11625
+ var fs$copyFile = fs.copyFile;
11626
+ if (fs$copyFile)
11627
+ fs.copyFile = copyFile;
11628
+ function copyFile (src, dest, flags, cb) {
11629
+ if (typeof flags === 'function') {
11630
+ cb = flags;
11631
+ flags = 0;
11632
+ }
11633
+ return go$copyFile(src, dest, flags, cb)
11634
+
11635
+ function go$copyFile (src, dest, flags, cb, startTime) {
11636
+ return fs$copyFile(src, dest, flags, function (err) {
11637
+ if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
11638
+ enqueue([go$copyFile, [src, dest, flags, cb], err, startTime || Date.now(), Date.now()]);
11639
+ else {
11640
+ if (typeof cb === 'function')
11641
+ cb.apply(this, arguments);
11642
+ }
11643
+ })
11644
+ }
11645
+ }
11646
+
11647
+ var fs$readdir = fs.readdir;
11648
+ fs.readdir = readdir;
11649
+ var noReaddirOptionVersions = /^v[0-5]\./;
11650
+ function readdir (path, options, cb) {
11651
+ if (typeof options === 'function')
11652
+ cb = options, options = null;
11653
+
11654
+ var go$readdir = noReaddirOptionVersions.test(process.version)
11655
+ ? function go$readdir (path, options, cb, startTime) {
11656
+ return fs$readdir(path, fs$readdirCallback(
11657
+ path, options, cb, startTime
11658
+ ))
11659
+ }
11660
+ : function go$readdir (path, options, cb, startTime) {
11661
+ return fs$readdir(path, options, fs$readdirCallback(
11662
+ path, options, cb, startTime
11663
+ ))
11664
+ };
11665
+
11666
+ return go$readdir(path, options, cb)
11667
+
11668
+ function fs$readdirCallback (path, options, cb, startTime) {
11669
+ return function (err, files) {
11670
+ if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
11671
+ enqueue([
11672
+ go$readdir,
11673
+ [path, options, cb],
11674
+ err,
11675
+ startTime || Date.now(),
11676
+ Date.now()
11677
+ ]);
11678
+ else {
11679
+ if (files && files.sort)
11680
+ files.sort();
11681
+
11682
+ if (typeof cb === 'function')
11683
+ cb.call(this, err, files);
11684
+ }
11685
+ }
11686
+ }
11687
+ }
11688
+
11689
+ if (process.version.substr(0, 4) === 'v0.8') {
11690
+ var legStreams = legacy(fs);
11691
+ ReadStream = legStreams.ReadStream;
11692
+ WriteStream = legStreams.WriteStream;
11693
+ }
11694
+
11695
+ var fs$ReadStream = fs.ReadStream;
11696
+ if (fs$ReadStream) {
11697
+ ReadStream.prototype = Object.create(fs$ReadStream.prototype);
11698
+ ReadStream.prototype.open = ReadStream$open;
11699
+ }
11700
+
11701
+ var fs$WriteStream = fs.WriteStream;
11702
+ if (fs$WriteStream) {
11703
+ WriteStream.prototype = Object.create(fs$WriteStream.prototype);
11704
+ WriteStream.prototype.open = WriteStream$open;
11705
+ }
11706
+
11707
+ Object.defineProperty(fs, 'ReadStream', {
11708
+ get: function () {
11709
+ return ReadStream
11710
+ },
11711
+ set: function (val) {
11712
+ ReadStream = val;
11713
+ },
11714
+ enumerable: true,
11715
+ configurable: true
11716
+ });
11717
+ Object.defineProperty(fs, 'WriteStream', {
11718
+ get: function () {
11719
+ return WriteStream
11720
+ },
11721
+ set: function (val) {
11722
+ WriteStream = val;
11723
+ },
11724
+ enumerable: true,
11725
+ configurable: true
11726
+ });
11727
+
11728
+ // legacy names
11729
+ var FileReadStream = ReadStream;
11730
+ Object.defineProperty(fs, 'FileReadStream', {
11731
+ get: function () {
11732
+ return FileReadStream
11733
+ },
11734
+ set: function (val) {
11735
+ FileReadStream = val;
11736
+ },
11737
+ enumerable: true,
11738
+ configurable: true
11739
+ });
11740
+ var FileWriteStream = WriteStream;
11741
+ Object.defineProperty(fs, 'FileWriteStream', {
11742
+ get: function () {
11743
+ return FileWriteStream
11744
+ },
11745
+ set: function (val) {
11746
+ FileWriteStream = val;
11747
+ },
11748
+ enumerable: true,
11749
+ configurable: true
11750
+ });
11751
+
11752
+ function ReadStream (path, options) {
11753
+ if (this instanceof ReadStream)
11754
+ return fs$ReadStream.apply(this, arguments), this
11755
+ else
11756
+ return ReadStream.apply(Object.create(ReadStream.prototype), arguments)
11757
+ }
11758
+
11759
+ function ReadStream$open () {
11760
+ var that = this;
11761
+ open(that.path, that.flags, that.mode, function (err, fd) {
11762
+ if (err) {
11763
+ if (that.autoClose)
11764
+ that.destroy();
11765
+
11766
+ that.emit('error', err);
11767
+ } else {
11768
+ that.fd = fd;
11769
+ that.emit('open', fd);
11770
+ that.read();
11771
+ }
11772
+ });
11773
+ }
11774
+
11775
+ function WriteStream (path, options) {
11776
+ if (this instanceof WriteStream)
11777
+ return fs$WriteStream.apply(this, arguments), this
11778
+ else
11779
+ return WriteStream.apply(Object.create(WriteStream.prototype), arguments)
11780
+ }
11781
+
11782
+ function WriteStream$open () {
11783
+ var that = this;
11784
+ open(that.path, that.flags, that.mode, function (err, fd) {
11785
+ if (err) {
11786
+ that.destroy();
11787
+ that.emit('error', err);
11788
+ } else {
11789
+ that.fd = fd;
11790
+ that.emit('open', fd);
11791
+ }
11792
+ });
11793
+ }
11794
+
11795
+ function createReadStream (path, options) {
11796
+ return new fs.ReadStream(path, options)
11797
+ }
11798
+
11799
+ function createWriteStream (path, options) {
11800
+ return new fs.WriteStream(path, options)
11801
+ }
11802
+
11803
+ var fs$open = fs.open;
11804
+ fs.open = open;
11805
+ function open (path, flags, mode, cb) {
11806
+ if (typeof mode === 'function')
11807
+ cb = mode, mode = null;
11808
+
11809
+ return go$open(path, flags, mode, cb)
11810
+
11811
+ function go$open (path, flags, mode, cb, startTime) {
11812
+ return fs$open(path, flags, mode, function (err, fd) {
11813
+ if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
11814
+ enqueue([go$open, [path, flags, mode, cb], err, startTime || Date.now(), Date.now()]);
11815
+ else {
11816
+ if (typeof cb === 'function')
11817
+ cb.apply(this, arguments);
11818
+ }
11819
+ })
11820
+ }
11821
+ }
11822
+
11823
+ return fs
11824
+ }
11825
+
11826
+ function enqueue (elem) {
11827
+ debug('ENQUEUE', elem[0].name, elem[1]);
11828
+ fs$g[gracefulQueue].push(elem);
11829
+ retry();
11830
+ }
11831
+
11832
+ // keep track of the timeout between retry() calls
11833
+ var retryTimer;
11834
+
11835
+ // reset the startTime and lastTime to now
11836
+ // this resets the start of the 60 second overall timeout as well as the
11837
+ // delay between attempts so that we'll retry these jobs sooner
11838
+ function resetQueue () {
11839
+ var now = Date.now();
11840
+ for (var i = 0; i < fs$g[gracefulQueue].length; ++i) {
11841
+ // entries that are only a length of 2 are from an older version, don't
11842
+ // bother modifying those since they'll be retried anyway.
11843
+ if (fs$g[gracefulQueue][i].length > 2) {
11844
+ fs$g[gracefulQueue][i][3] = now; // startTime
11845
+ fs$g[gracefulQueue][i][4] = now; // lastTime
11846
+ }
11847
+ }
11848
+ // call retry to make sure we're actively processing the queue
11849
+ retry();
11850
+ }
11851
+
11852
+ function retry () {
11853
+ // clear the timer and remove it to help prevent unintended concurrency
11854
+ clearTimeout(retryTimer);
11855
+ retryTimer = undefined;
11856
+
11857
+ if (fs$g[gracefulQueue].length === 0)
11858
+ return
11859
+
11860
+ var elem = fs$g[gracefulQueue].shift();
11861
+ var fn = elem[0];
11862
+ var args = elem[1];
11863
+ // these items may be unset if they were added by an older graceful-fs
11864
+ var err = elem[2];
11865
+ var startTime = elem[3];
11866
+ var lastTime = elem[4];
11867
+
11868
+ // if we don't have a startTime we have no way of knowing if we've waited
11869
+ // long enough, so go ahead and retry this item now
11870
+ if (startTime === undefined) {
11871
+ debug('RETRY', fn.name, args);
11872
+ fn.apply(null, args);
11873
+ } else if (Date.now() - startTime >= 60000) {
11874
+ // it's been more than 60 seconds total, bail now
11875
+ debug('TIMEOUT', fn.name, args);
11876
+ var cb = args.pop();
11877
+ if (typeof cb === 'function')
11878
+ cb.call(null, err);
11879
+ } else {
11880
+ // the amount of time between the last attempt and right now
11881
+ var sinceAttempt = Date.now() - lastTime;
11882
+ // the amount of time between when we first tried, and when we last tried
11883
+ // rounded up to at least 1
11884
+ var sinceStart = Math.max(lastTime - startTime, 1);
11885
+ // backoff. wait longer than the total time we've been retrying, but only
11886
+ // up to a maximum of 100ms
11887
+ var desiredDelay = Math.min(sinceStart * 1.2, 100);
11888
+ // it's been long enough since the last retry, do it again
11889
+ if (sinceAttempt >= desiredDelay) {
11890
+ debug('RETRY', fn.name, args);
11891
+ fn.apply(null, args.concat([startTime]));
11892
+ } else {
11893
+ // if we can't do this job yet, push it to the end of the queue
11894
+ // and let the next iteration check again
11895
+ fs$g[gracefulQueue].push(elem);
11896
+ }
11897
+ }
11898
+
11899
+ // schedule our next run if one isn't already scheduled
11900
+ if (retryTimer === undefined) {
11901
+ retryTimer = setTimeout(retry, 0);
11902
+ }
11903
+ }
11904
+
11905
+ (function (exports) {
11906
+ // This is adapted from https://github.com/normalize/mz
11907
+ // Copyright (c) 2014-2016 Jonathan Ong me@jongleberry.com and Contributors
11908
+ const u = universalify$1.fromCallback;
11909
+ const fs = gracefulFs;
11910
+
11911
+ const api = [
11912
+ 'access',
11913
+ 'appendFile',
11914
+ 'chmod',
11915
+ 'chown',
11916
+ 'close',
11917
+ 'copyFile',
11918
+ 'fchmod',
11919
+ 'fchown',
11920
+ 'fdatasync',
11921
+ 'fstat',
11922
+ 'fsync',
11923
+ 'ftruncate',
11924
+ 'futimes',
11925
+ 'lchmod',
11926
+ 'lchown',
11927
+ 'link',
11928
+ 'lstat',
11929
+ 'mkdir',
11930
+ 'mkdtemp',
11931
+ 'open',
11932
+ 'opendir',
11933
+ 'readdir',
11934
+ 'readFile',
11935
+ 'readlink',
11936
+ 'realpath',
11937
+ 'rename',
11938
+ 'rm',
11939
+ 'rmdir',
11940
+ 'stat',
11941
+ 'symlink',
11942
+ 'truncate',
11943
+ 'unlink',
11944
+ 'utimes',
11945
+ 'writeFile'
11946
+ ].filter(key => {
11947
+ // Some commands are not available on some systems. Ex:
11948
+ // fs.cp was added in Node.js v16.7.0
11949
+ // fs.lchown is not available on at least some Linux
11950
+ return typeof fs[key] === 'function'
11951
+ });
11952
+
11953
+ // Export cloned fs:
11954
+ Object.assign(exports, fs);
11955
+
11956
+ // Universalify async methods:
11957
+ api.forEach(method => {
11958
+ exports[method] = u(fs[method]);
11959
+ });
11960
+
11961
+ // We differ from mz/fs in that we still ship the old, broken, fs.exists()
11962
+ // since we are a drop-in replacement for the native module
11963
+ exports.exists = function (filename, callback) {
11964
+ if (typeof callback === 'function') {
11965
+ return fs.exists(filename, callback)
11966
+ }
11967
+ return new Promise(resolve => {
11968
+ return fs.exists(filename, resolve)
11969
+ })
11970
+ };
11971
+
11972
+ // fs.read(), fs.write(), fs.readv(), & fs.writev() need special treatment due to multiple callback args
11973
+
11974
+ exports.read = function (fd, buffer, offset, length, position, callback) {
11975
+ if (typeof callback === 'function') {
11976
+ return fs.read(fd, buffer, offset, length, position, callback)
11977
+ }
11978
+ return new Promise((resolve, reject) => {
11979
+ fs.read(fd, buffer, offset, length, position, (err, bytesRead, buffer) => {
11980
+ if (err) return reject(err)
11981
+ resolve({ bytesRead, buffer });
11982
+ });
11983
+ })
11984
+ };
11985
+
11986
+ // Function signature can be
11987
+ // fs.write(fd, buffer[, offset[, length[, position]]], callback)
11988
+ // OR
11989
+ // fs.write(fd, string[, position[, encoding]], callback)
11990
+ // We need to handle both cases, so we use ...args
11991
+ exports.write = function (fd, buffer, ...args) {
11992
+ if (typeof args[args.length - 1] === 'function') {
11993
+ return fs.write(fd, buffer, ...args)
11994
+ }
11995
+
11996
+ return new Promise((resolve, reject) => {
11997
+ fs.write(fd, buffer, ...args, (err, bytesWritten, buffer) => {
11998
+ if (err) return reject(err)
11999
+ resolve({ bytesWritten, buffer });
12000
+ });
12001
+ })
12002
+ };
12003
+
12004
+ // Function signature is
12005
+ // s.readv(fd, buffers[, position], callback)
12006
+ // We need to handle the optional arg, so we use ...args
12007
+ exports.readv = function (fd, buffers, ...args) {
12008
+ if (typeof args[args.length - 1] === 'function') {
12009
+ return fs.readv(fd, buffers, ...args)
12010
+ }
12011
+
12012
+ return new Promise((resolve, reject) => {
12013
+ fs.readv(fd, buffers, ...args, (err, bytesRead, buffers) => {
12014
+ if (err) return reject(err)
12015
+ resolve({ bytesRead, buffers });
12016
+ });
12017
+ })
12018
+ };
12019
+
12020
+ // Function signature is
12021
+ // s.writev(fd, buffers[, position], callback)
12022
+ // We need to handle the optional arg, so we use ...args
12023
+ exports.writev = function (fd, buffers, ...args) {
12024
+ if (typeof args[args.length - 1] === 'function') {
12025
+ return fs.writev(fd, buffers, ...args)
12026
+ }
12027
+
12028
+ return new Promise((resolve, reject) => {
12029
+ fs.writev(fd, buffers, ...args, (err, bytesWritten, buffers) => {
12030
+ if (err) return reject(err)
12031
+ resolve({ bytesWritten, buffers });
12032
+ });
12033
+ })
12034
+ };
12035
+
12036
+ // fs.realpath.native sometimes not available if fs is monkey-patched
12037
+ if (typeof fs.realpath.native === 'function') {
12038
+ exports.realpath.native = u(fs.realpath.native);
12039
+ } else {
12040
+ process.emitWarning(
12041
+ 'fs.realpath.native is not a function. Is fs being monkey-patched?',
12042
+ 'Warning', 'fs-extra-WARN0003'
12043
+ );
12044
+ }
12045
+ } (fs$h));
12046
+
12047
+ var makeDir$1 = {};
12048
+
12049
+ var utils$1 = {};
12050
+
12051
+ const path$b = require$$1;
12052
+
12053
+ // https://github.com/nodejs/node/issues/8987
12054
+ // https://github.com/libuv/libuv/pull/1088
12055
+ utils$1.checkPath = function checkPath (pth) {
12056
+ if (process.platform === 'win32') {
12057
+ const pathHasInvalidWinCharacters = /[<>:"|?*]/.test(pth.replace(path$b.parse(pth).root, ''));
12058
+
12059
+ if (pathHasInvalidWinCharacters) {
12060
+ const error = new Error(`Path contains invalid characters: ${pth}`);
12061
+ error.code = 'EINVAL';
12062
+ throw error
12063
+ }
12064
+ }
12065
+ };
12066
+
12067
+ const fs$f = fs$h;
12068
+ const { checkPath } = utils$1;
12069
+
12070
+ const getMode = options => {
12071
+ const defaults = { mode: 0o777 };
12072
+ if (typeof options === 'number') return options
12073
+ return ({ ...defaults, ...options }).mode
12074
+ };
12075
+
12076
+ makeDir$1.makeDir = async (dir, options) => {
12077
+ checkPath(dir);
12078
+
12079
+ return fs$f.mkdir(dir, {
12080
+ mode: getMode(options),
12081
+ recursive: true
12082
+ })
12083
+ };
12084
+
12085
+ makeDir$1.makeDirSync = (dir, options) => {
12086
+ checkPath(dir);
12087
+
12088
+ return fs$f.mkdirSync(dir, {
12089
+ mode: getMode(options),
12090
+ recursive: true
12091
+ })
12092
+ };
12093
+
12094
+ const u$e = universalify$1.fromPromise;
12095
+ const { makeDir: _makeDir, makeDirSync } = makeDir$1;
12096
+ const makeDir = u$e(_makeDir);
12097
+
12098
+ var mkdirs$2 = {
12099
+ mkdirs: makeDir,
12100
+ mkdirsSync: makeDirSync,
12101
+ // alias
12102
+ mkdirp: makeDir,
12103
+ mkdirpSync: makeDirSync,
12104
+ ensureDir: makeDir,
12105
+ ensureDirSync: makeDirSync
12106
+ };
12107
+
12108
+ const u$d = universalify$1.fromPromise;
12109
+ const fs$e = fs$h;
12110
+
12111
+ function pathExists$6 (path) {
12112
+ return fs$e.access(path).then(() => true).catch(() => false)
12113
+ }
12114
+
12115
+ var pathExists_1 = {
12116
+ pathExists: u$d(pathExists$6),
12117
+ pathExistsSync: fs$e.existsSync
12118
+ };
12119
+
12120
+ const fs$d = fs$h;
12121
+ const u$c = universalify$1.fromPromise;
12122
+
12123
+ async function utimesMillis$1 (path, atime, mtime) {
12124
+ // if (!HAS_MILLIS_RES) return fs.utimes(path, atime, mtime, callback)
12125
+ const fd = await fs$d.open(path, 'r+');
12126
+
12127
+ let closeErr = null;
12128
+
12129
+ try {
12130
+ await fs$d.futimes(fd, atime, mtime);
12131
+ } finally {
12132
+ try {
12133
+ await fs$d.close(fd);
12134
+ } catch (e) {
12135
+ closeErr = e;
12136
+ }
12137
+ }
12138
+
12139
+ if (closeErr) {
12140
+ throw closeErr
12141
+ }
12142
+ }
12143
+
12144
+ function utimesMillisSync$1 (path, atime, mtime) {
12145
+ const fd = fs$d.openSync(path, 'r+');
12146
+ fs$d.futimesSync(fd, atime, mtime);
12147
+ return fs$d.closeSync(fd)
12148
+ }
12149
+
12150
+ var utimes = {
12151
+ utimesMillis: u$c(utimesMillis$1),
12152
+ utimesMillisSync: utimesMillisSync$1
12153
+ };
12154
+
12155
+ const fs$c = fs$h;
12156
+ const path$a = require$$1;
12157
+ const u$b = universalify$1.fromPromise;
12158
+
12159
+ function getStats$1 (src, dest, opts) {
12160
+ const statFunc = opts.dereference
12161
+ ? (file) => fs$c.stat(file, { bigint: true })
12162
+ : (file) => fs$c.lstat(file, { bigint: true });
12163
+ return Promise.all([
12164
+ statFunc(src),
12165
+ statFunc(dest).catch(err => {
12166
+ if (err.code === 'ENOENT') return null
12167
+ throw err
12168
+ })
12169
+ ]).then(([srcStat, destStat]) => ({ srcStat, destStat }))
12170
+ }
12171
+
12172
+ function getStatsSync (src, dest, opts) {
12173
+ let destStat;
12174
+ const statFunc = opts.dereference
12175
+ ? (file) => fs$c.statSync(file, { bigint: true })
12176
+ : (file) => fs$c.lstatSync(file, { bigint: true });
12177
+ const srcStat = statFunc(src);
12178
+ try {
12179
+ destStat = statFunc(dest);
12180
+ } catch (err) {
12181
+ if (err.code === 'ENOENT') return { srcStat, destStat: null }
12182
+ throw err
12183
+ }
12184
+ return { srcStat, destStat }
12185
+ }
12186
+
12187
+ async function checkPaths (src, dest, funcName, opts) {
12188
+ const { srcStat, destStat } = await getStats$1(src, dest, opts);
12189
+ if (destStat) {
12190
+ if (areIdentical$2(srcStat, destStat)) {
12191
+ const srcBaseName = path$a.basename(src);
12192
+ const destBaseName = path$a.basename(dest);
12193
+ if (funcName === 'move' &&
12194
+ srcBaseName !== destBaseName &&
12195
+ srcBaseName.toLowerCase() === destBaseName.toLowerCase()) {
12196
+ return { srcStat, destStat, isChangingCase: true }
12197
+ }
12198
+ throw new Error('Source and destination must not be the same.')
12199
+ }
12200
+ if (srcStat.isDirectory() && !destStat.isDirectory()) {
12201
+ throw new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`)
12202
+ }
12203
+ if (!srcStat.isDirectory() && destStat.isDirectory()) {
12204
+ throw new Error(`Cannot overwrite directory '${dest}' with non-directory '${src}'.`)
12205
+ }
12206
+ }
12207
+
12208
+ if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
12209
+ throw new Error(errMsg(src, dest, funcName))
12210
+ }
12211
+
12212
+ return { srcStat, destStat }
12213
+ }
12214
+
12215
+ function checkPathsSync (src, dest, funcName, opts) {
12216
+ const { srcStat, destStat } = getStatsSync(src, dest, opts);
12217
+
12218
+ if (destStat) {
12219
+ if (areIdentical$2(srcStat, destStat)) {
12220
+ const srcBaseName = path$a.basename(src);
12221
+ const destBaseName = path$a.basename(dest);
12222
+ if (funcName === 'move' &&
12223
+ srcBaseName !== destBaseName &&
12224
+ srcBaseName.toLowerCase() === destBaseName.toLowerCase()) {
12225
+ return { srcStat, destStat, isChangingCase: true }
12226
+ }
12227
+ throw new Error('Source and destination must not be the same.')
12228
+ }
12229
+ if (srcStat.isDirectory() && !destStat.isDirectory()) {
12230
+ throw new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`)
12231
+ }
12232
+ if (!srcStat.isDirectory() && destStat.isDirectory()) {
12233
+ throw new Error(`Cannot overwrite directory '${dest}' with non-directory '${src}'.`)
12234
+ }
12235
+ }
12236
+
12237
+ if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
12238
+ throw new Error(errMsg(src, dest, funcName))
12239
+ }
12240
+ return { srcStat, destStat }
12241
+ }
12242
+
12243
+ // recursively check if dest parent is a subdirectory of src.
12244
+ // It works for all file types including symlinks since it
12245
+ // checks the src and dest inodes. It starts from the deepest
12246
+ // parent and stops once it reaches the src parent or the root path.
12247
+ async function checkParentPaths (src, srcStat, dest, funcName) {
12248
+ const srcParent = path$a.resolve(path$a.dirname(src));
12249
+ const destParent = path$a.resolve(path$a.dirname(dest));
12250
+ if (destParent === srcParent || destParent === path$a.parse(destParent).root) return
12251
+
12252
+ let destStat;
12253
+ try {
12254
+ destStat = await fs$c.stat(destParent, { bigint: true });
12255
+ } catch (err) {
12256
+ if (err.code === 'ENOENT') return
12257
+ throw err
12258
+ }
12259
+
12260
+ if (areIdentical$2(srcStat, destStat)) {
12261
+ throw new Error(errMsg(src, dest, funcName))
12262
+ }
12263
+
12264
+ return checkParentPaths(src, srcStat, destParent, funcName)
12265
+ }
12266
+
12267
+ function checkParentPathsSync (src, srcStat, dest, funcName) {
12268
+ const srcParent = path$a.resolve(path$a.dirname(src));
12269
+ const destParent = path$a.resolve(path$a.dirname(dest));
12270
+ if (destParent === srcParent || destParent === path$a.parse(destParent).root) return
12271
+ let destStat;
12272
+ try {
12273
+ destStat = fs$c.statSync(destParent, { bigint: true });
12274
+ } catch (err) {
12275
+ if (err.code === 'ENOENT') return
12276
+ throw err
12277
+ }
12278
+ if (areIdentical$2(srcStat, destStat)) {
12279
+ throw new Error(errMsg(src, dest, funcName))
12280
+ }
12281
+ return checkParentPathsSync(src, srcStat, destParent, funcName)
12282
+ }
12283
+
12284
+ function areIdentical$2 (srcStat, destStat) {
12285
+ return destStat.ino && destStat.dev && destStat.ino === srcStat.ino && destStat.dev === srcStat.dev
12286
+ }
12287
+
12288
+ // return true if dest is a subdir of src, otherwise false.
12289
+ // It only checks the path strings.
12290
+ function isSrcSubdir (src, dest) {
12291
+ const srcArr = path$a.resolve(src).split(path$a.sep).filter(i => i);
12292
+ const destArr = path$a.resolve(dest).split(path$a.sep).filter(i => i);
12293
+ return srcArr.every((cur, i) => destArr[i] === cur)
12294
+ }
12295
+
12296
+ function errMsg (src, dest, funcName) {
12297
+ return `Cannot ${funcName} '${src}' to a subdirectory of itself, '${dest}'.`
12298
+ }
12299
+
12300
+ var stat$4 = {
12301
+ // checkPaths
12302
+ checkPaths: u$b(checkPaths),
12303
+ checkPathsSync,
12304
+ // checkParent
12305
+ checkParentPaths: u$b(checkParentPaths),
12306
+ checkParentPathsSync,
12307
+ // Misc
12308
+ isSrcSubdir,
12309
+ areIdentical: areIdentical$2
12310
+ };
12311
+
12312
+ const fs$b = fs$h;
12313
+ const path$9 = require$$1;
12314
+ const { mkdirs: mkdirs$1 } = mkdirs$2;
12315
+ const { pathExists: pathExists$5 } = pathExists_1;
12316
+ const { utimesMillis } = utimes;
12317
+ const stat$3 = stat$4;
12318
+
12319
+ async function copy$2 (src, dest, opts = {}) {
12320
+ if (typeof opts === 'function') {
12321
+ opts = { filter: opts };
12322
+ }
12323
+
12324
+ opts.clobber = 'clobber' in opts ? !!opts.clobber : true; // default to true for now
12325
+ opts.overwrite = 'overwrite' in opts ? !!opts.overwrite : opts.clobber; // overwrite falls back to clobber
12326
+
12327
+ // Warn about using preserveTimestamps on 32-bit node
12328
+ if (opts.preserveTimestamps && process.arch === 'ia32') {
12329
+ process.emitWarning(
12330
+ 'Using the preserveTimestamps option in 32-bit node is not recommended;\n\n' +
12331
+ '\tsee https://github.com/jprichardson/node-fs-extra/issues/269',
12332
+ 'Warning', 'fs-extra-WARN0001'
12333
+ );
12334
+ }
12335
+
12336
+ const { srcStat, destStat } = await stat$3.checkPaths(src, dest, 'copy', opts);
12337
+
12338
+ await stat$3.checkParentPaths(src, srcStat, dest, 'copy');
12339
+
12340
+ const include = await runFilter(src, dest, opts);
12341
+
12342
+ if (!include) return
12343
+
12344
+ // check if the parent of dest exists, and create it if it doesn't exist
12345
+ const destParent = path$9.dirname(dest);
12346
+ const dirExists = await pathExists$5(destParent);
12347
+ if (!dirExists) {
12348
+ await mkdirs$1(destParent);
12349
+ }
12350
+
12351
+ await getStatsAndPerformCopy(destStat, src, dest, opts);
12352
+ }
12353
+
12354
+ async function runFilter (src, dest, opts) {
12355
+ if (!opts.filter) return true
12356
+ return opts.filter(src, dest)
12357
+ }
12358
+
12359
+ async function getStatsAndPerformCopy (destStat, src, dest, opts) {
12360
+ const statFn = opts.dereference ? fs$b.stat : fs$b.lstat;
12361
+ const srcStat = await statFn(src);
12362
+
12363
+ if (srcStat.isDirectory()) return onDir$1(srcStat, destStat, src, dest, opts)
12364
+
12365
+ if (
12366
+ srcStat.isFile() ||
12367
+ srcStat.isCharacterDevice() ||
12368
+ srcStat.isBlockDevice()
12369
+ ) return onFile$1(srcStat, destStat, src, dest, opts)
12370
+
12371
+ if (srcStat.isSymbolicLink()) return onLink$1(destStat, src, dest, opts)
12372
+ if (srcStat.isSocket()) throw new Error(`Cannot copy a socket file: ${src}`)
12373
+ if (srcStat.isFIFO()) throw new Error(`Cannot copy a FIFO pipe: ${src}`)
12374
+ throw new Error(`Unknown file: ${src}`)
12375
+ }
12376
+
12377
+ async function onFile$1 (srcStat, destStat, src, dest, opts) {
12378
+ if (!destStat) return copyFile$1(srcStat, src, dest, opts)
12379
+
12380
+ if (opts.overwrite) {
12381
+ await fs$b.unlink(dest);
12382
+ return copyFile$1(srcStat, src, dest, opts)
12383
+ }
12384
+ if (opts.errorOnExist) {
12385
+ throw new Error(`'${dest}' already exists`)
12386
+ }
12387
+ }
12388
+
12389
+ async function copyFile$1 (srcStat, src, dest, opts) {
12390
+ await fs$b.copyFile(src, dest);
12391
+ if (opts.preserveTimestamps) {
12392
+ // Make sure the file is writable before setting the timestamp
12393
+ // otherwise open fails with EPERM when invoked with 'r+'
12394
+ // (through utimes call)
12395
+ if (fileIsNotWritable$1(srcStat.mode)) {
12396
+ await makeFileWritable$1(dest, srcStat.mode);
12397
+ }
12398
+
12399
+ // Set timestamps and mode correspondingly
12400
+
12401
+ // Note that The initial srcStat.atime cannot be trusted
12402
+ // because it is modified by the read(2) system call
12403
+ // (See https://nodejs.org/api/fs.html#fs_stat_time_values)
12404
+ const updatedSrcStat = await fs$b.stat(src);
12405
+ await utimesMillis(dest, updatedSrcStat.atime, updatedSrcStat.mtime);
12406
+ }
12407
+
12408
+ return fs$b.chmod(dest, srcStat.mode)
12409
+ }
12410
+
12411
+ function fileIsNotWritable$1 (srcMode) {
12412
+ return (srcMode & 0o200) === 0
12413
+ }
12414
+
12415
+ function makeFileWritable$1 (dest, srcMode) {
12416
+ return fs$b.chmod(dest, srcMode | 0o200)
12417
+ }
12418
+
12419
+ async function onDir$1 (srcStat, destStat, src, dest, opts) {
12420
+ // the dest directory might not exist, create it
12421
+ if (!destStat) {
12422
+ await fs$b.mkdir(dest);
12423
+ }
12424
+
12425
+ const items = await fs$b.readdir(src);
12426
+
12427
+ // loop through the files in the current directory to copy everything
12428
+ await Promise.all(items.map(async item => {
12429
+ const srcItem = path$9.join(src, item);
12430
+ const destItem = path$9.join(dest, item);
12431
+
12432
+ // skip the item if it is matches by the filter function
12433
+ const include = await runFilter(srcItem, destItem, opts);
12434
+ if (!include) return
12435
+
12436
+ const { destStat } = await stat$3.checkPaths(srcItem, destItem, 'copy', opts);
12437
+
12438
+ // If the item is a copyable file, `getStatsAndPerformCopy` will copy it
12439
+ // If the item is a directory, `getStatsAndPerformCopy` will call `onDir` recursively
12440
+ return getStatsAndPerformCopy(destStat, srcItem, destItem, opts)
12441
+ }));
12442
+
12443
+ if (!destStat) {
12444
+ await fs$b.chmod(dest, srcStat.mode);
12445
+ }
12446
+ }
12447
+
12448
+ async function onLink$1 (destStat, src, dest, opts) {
12449
+ let resolvedSrc = await fs$b.readlink(src);
12450
+ if (opts.dereference) {
12451
+ resolvedSrc = path$9.resolve(process.cwd(), resolvedSrc);
12452
+ }
12453
+ if (!destStat) {
12454
+ return fs$b.symlink(resolvedSrc, dest)
12455
+ }
12456
+
12457
+ let resolvedDest = null;
12458
+ try {
12459
+ resolvedDest = await fs$b.readlink(dest);
12460
+ } catch (e) {
12461
+ // dest exists and is a regular file or directory,
12462
+ // Windows may throw UNKNOWN error. If dest already exists,
12463
+ // fs throws error anyway, so no need to guard against it here.
12464
+ if (e.code === 'EINVAL' || e.code === 'UNKNOWN') return fs$b.symlink(resolvedSrc, dest)
12465
+ throw e
12466
+ }
12467
+ if (opts.dereference) {
12468
+ resolvedDest = path$9.resolve(process.cwd(), resolvedDest);
12469
+ }
12470
+ if (stat$3.isSrcSubdir(resolvedSrc, resolvedDest)) {
12471
+ throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`)
12472
+ }
12473
+
12474
+ // do not copy if src is a subdir of dest since unlinking
12475
+ // dest in this case would result in removing src contents
12476
+ // and therefore a broken symlink would be created.
12477
+ if (stat$3.isSrcSubdir(resolvedDest, resolvedSrc)) {
12478
+ throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`)
12479
+ }
12480
+
12481
+ // copy the link
12482
+ await fs$b.unlink(dest);
12483
+ return fs$b.symlink(resolvedSrc, dest)
12484
+ }
12485
+
12486
+ var copy_1 = copy$2;
12487
+
12488
+ const fs$a = gracefulFs;
12489
+ const path$8 = require$$1;
12490
+ const mkdirsSync$1 = mkdirs$2.mkdirsSync;
12491
+ const utimesMillisSync = utimes.utimesMillisSync;
12492
+ const stat$2 = stat$4;
12493
+
12494
+ function copySync$1 (src, dest, opts) {
12495
+ if (typeof opts === 'function') {
12496
+ opts = { filter: opts };
12497
+ }
12498
+
12499
+ opts = opts || {};
12500
+ opts.clobber = 'clobber' in opts ? !!opts.clobber : true; // default to true for now
12501
+ opts.overwrite = 'overwrite' in opts ? !!opts.overwrite : opts.clobber; // overwrite falls back to clobber
12502
+
12503
+ // Warn about using preserveTimestamps on 32-bit node
12504
+ if (opts.preserveTimestamps && process.arch === 'ia32') {
12505
+ process.emitWarning(
12506
+ 'Using the preserveTimestamps option in 32-bit node is not recommended;\n\n' +
12507
+ '\tsee https://github.com/jprichardson/node-fs-extra/issues/269',
12508
+ 'Warning', 'fs-extra-WARN0002'
12509
+ );
12510
+ }
12511
+
12512
+ const { srcStat, destStat } = stat$2.checkPathsSync(src, dest, 'copy', opts);
12513
+ stat$2.checkParentPathsSync(src, srcStat, dest, 'copy');
12514
+ if (opts.filter && !opts.filter(src, dest)) return
12515
+ const destParent = path$8.dirname(dest);
12516
+ if (!fs$a.existsSync(destParent)) mkdirsSync$1(destParent);
12517
+ return getStats(destStat, src, dest, opts)
12518
+ }
12519
+
12520
+ function getStats (destStat, src, dest, opts) {
12521
+ const statSync = opts.dereference ? fs$a.statSync : fs$a.lstatSync;
12522
+ const srcStat = statSync(src);
12523
+
12524
+ if (srcStat.isDirectory()) return onDir(srcStat, destStat, src, dest, opts)
12525
+ else if (srcStat.isFile() ||
12526
+ srcStat.isCharacterDevice() ||
12527
+ srcStat.isBlockDevice()) return onFile(srcStat, destStat, src, dest, opts)
12528
+ else if (srcStat.isSymbolicLink()) return onLink(destStat, src, dest, opts)
12529
+ else if (srcStat.isSocket()) throw new Error(`Cannot copy a socket file: ${src}`)
12530
+ else if (srcStat.isFIFO()) throw new Error(`Cannot copy a FIFO pipe: ${src}`)
12531
+ throw new Error(`Unknown file: ${src}`)
12532
+ }
12533
+
12534
+ function onFile (srcStat, destStat, src, dest, opts) {
12535
+ if (!destStat) return copyFile(srcStat, src, dest, opts)
12536
+ return mayCopyFile(srcStat, src, dest, opts)
12537
+ }
12538
+
12539
+ function mayCopyFile (srcStat, src, dest, opts) {
12540
+ if (opts.overwrite) {
12541
+ fs$a.unlinkSync(dest);
12542
+ return copyFile(srcStat, src, dest, opts)
12543
+ } else if (opts.errorOnExist) {
12544
+ throw new Error(`'${dest}' already exists`)
12545
+ }
12546
+ }
12547
+
12548
+ function copyFile (srcStat, src, dest, opts) {
12549
+ fs$a.copyFileSync(src, dest);
12550
+ if (opts.preserveTimestamps) handleTimestamps(srcStat.mode, src, dest);
12551
+ return setDestMode(dest, srcStat.mode)
12552
+ }
12553
+
12554
+ function handleTimestamps (srcMode, src, dest) {
12555
+ // Make sure the file is writable before setting the timestamp
12556
+ // otherwise open fails with EPERM when invoked with 'r+'
12557
+ // (through utimes call)
12558
+ if (fileIsNotWritable(srcMode)) makeFileWritable(dest, srcMode);
12559
+ return setDestTimestamps(src, dest)
12560
+ }
12561
+
12562
+ function fileIsNotWritable (srcMode) {
12563
+ return (srcMode & 0o200) === 0
12564
+ }
12565
+
12566
+ function makeFileWritable (dest, srcMode) {
12567
+ return setDestMode(dest, srcMode | 0o200)
12568
+ }
12569
+
12570
+ function setDestMode (dest, srcMode) {
12571
+ return fs$a.chmodSync(dest, srcMode)
12572
+ }
12573
+
12574
+ function setDestTimestamps (src, dest) {
12575
+ // The initial srcStat.atime cannot be trusted
12576
+ // because it is modified by the read(2) system call
12577
+ // (See https://nodejs.org/api/fs.html#fs_stat_time_values)
12578
+ const updatedSrcStat = fs$a.statSync(src);
12579
+ return utimesMillisSync(dest, updatedSrcStat.atime, updatedSrcStat.mtime)
12580
+ }
12581
+
12582
+ function onDir (srcStat, destStat, src, dest, opts) {
12583
+ if (!destStat) return mkDirAndCopy(srcStat.mode, src, dest, opts)
12584
+ return copyDir(src, dest, opts)
12585
+ }
12586
+
12587
+ function mkDirAndCopy (srcMode, src, dest, opts) {
12588
+ fs$a.mkdirSync(dest);
12589
+ copyDir(src, dest, opts);
12590
+ return setDestMode(dest, srcMode)
12591
+ }
12592
+
12593
+ function copyDir (src, dest, opts) {
12594
+ fs$a.readdirSync(src).forEach(item => copyDirItem(item, src, dest, opts));
12595
+ }
12596
+
12597
+ function copyDirItem (item, src, dest, opts) {
12598
+ const srcItem = path$8.join(src, item);
12599
+ const destItem = path$8.join(dest, item);
12600
+ if (opts.filter && !opts.filter(srcItem, destItem)) return
12601
+ const { destStat } = stat$2.checkPathsSync(srcItem, destItem, 'copy', opts);
12602
+ return getStats(destStat, srcItem, destItem, opts)
12603
+ }
12604
+
12605
+ function onLink (destStat, src, dest, opts) {
12606
+ let resolvedSrc = fs$a.readlinkSync(src);
12607
+ if (opts.dereference) {
12608
+ resolvedSrc = path$8.resolve(process.cwd(), resolvedSrc);
12609
+ }
12610
+
12611
+ if (!destStat) {
12612
+ return fs$a.symlinkSync(resolvedSrc, dest)
12613
+ } else {
12614
+ let resolvedDest;
12615
+ try {
12616
+ resolvedDest = fs$a.readlinkSync(dest);
12617
+ } catch (err) {
12618
+ // dest exists and is a regular file or directory,
12619
+ // Windows may throw UNKNOWN error. If dest already exists,
12620
+ // fs throws error anyway, so no need to guard against it here.
12621
+ if (err.code === 'EINVAL' || err.code === 'UNKNOWN') return fs$a.symlinkSync(resolvedSrc, dest)
12622
+ throw err
12623
+ }
12624
+ if (opts.dereference) {
12625
+ resolvedDest = path$8.resolve(process.cwd(), resolvedDest);
12626
+ }
12627
+ if (stat$2.isSrcSubdir(resolvedSrc, resolvedDest)) {
12628
+ throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`)
12629
+ }
12630
+
12631
+ // prevent copy if src is a subdir of dest since unlinking
12632
+ // dest in this case would result in removing src contents
12633
+ // and therefore a broken symlink would be created.
12634
+ if (stat$2.isSrcSubdir(resolvedDest, resolvedSrc)) {
12635
+ throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`)
12636
+ }
12637
+ return copyLink(resolvedSrc, dest)
12638
+ }
12639
+ }
12640
+
12641
+ function copyLink (resolvedSrc, dest) {
12642
+ fs$a.unlinkSync(dest);
12643
+ return fs$a.symlinkSync(resolvedSrc, dest)
12644
+ }
12645
+
12646
+ var copySync_1 = copySync$1;
12647
+
12648
+ const u$a = universalify$1.fromPromise;
12649
+ var copy$1 = {
12650
+ copy: u$a(copy_1),
12651
+ copySync: copySync_1
12652
+ };
12653
+
12654
+ const fs$9 = gracefulFs;
12655
+ const u$9 = universalify$1.fromCallback;
12656
+
12657
+ function remove$2 (path, callback) {
12658
+ fs$9.rm(path, { recursive: true, force: true }, callback);
12659
+ }
12660
+
12661
+ function removeSync$1 (path) {
12662
+ fs$9.rmSync(path, { recursive: true, force: true });
12663
+ }
12664
+
12665
+ var remove_1 = {
12666
+ remove: u$9(remove$2),
12667
+ removeSync: removeSync$1
12668
+ };
12669
+
12670
+ const u$8 = universalify$1.fromPromise;
12671
+ const fs$8 = fs$h;
12672
+ const path$7 = require$$1;
12673
+ const mkdir$3 = mkdirs$2;
12674
+ const remove$1 = remove_1;
12675
+
12676
+ const emptyDir = u$8(async function emptyDir (dir) {
12677
+ let items;
12678
+ try {
12679
+ items = await fs$8.readdir(dir);
12680
+ } catch {
12681
+ return mkdir$3.mkdirs(dir)
12682
+ }
12683
+
12684
+ return Promise.all(items.map(item => remove$1.remove(path$7.join(dir, item))))
12685
+ });
12686
+
12687
+ function emptyDirSync (dir) {
12688
+ let items;
12689
+ try {
12690
+ items = fs$8.readdirSync(dir);
12691
+ } catch {
12692
+ return mkdir$3.mkdirsSync(dir)
12693
+ }
12694
+
12695
+ items.forEach(item => {
12696
+ item = path$7.join(dir, item);
12697
+ remove$1.removeSync(item);
12698
+ });
12699
+ }
12700
+
12701
+ var empty = {
12702
+ emptyDirSync,
12703
+ emptydirSync: emptyDirSync,
12704
+ emptyDir,
12705
+ emptydir: emptyDir
12706
+ };
12707
+
12708
+ const u$7 = universalify$1.fromPromise;
12709
+ const path$6 = require$$1;
12710
+ const fs$7 = fs$h;
12711
+ const mkdir$2 = mkdirs$2;
12712
+
12713
+ async function createFile$1 (file) {
12714
+ let stats;
12715
+ try {
12716
+ stats = await fs$7.stat(file);
12717
+ } catch { }
12718
+ if (stats && stats.isFile()) return
12719
+
12720
+ const dir = path$6.dirname(file);
12721
+
12722
+ let dirStats = null;
12723
+ try {
12724
+ dirStats = await fs$7.stat(dir);
12725
+ } catch (err) {
12726
+ // if the directory doesn't exist, make it
12727
+ if (err.code === 'ENOENT') {
12728
+ await mkdir$2.mkdirs(dir);
12729
+ await fs$7.writeFile(file, '');
12730
+ return
12731
+ } else {
12732
+ throw err
12733
+ }
12734
+ }
12735
+
12736
+ if (dirStats.isDirectory()) {
12737
+ await fs$7.writeFile(file, '');
12738
+ } else {
12739
+ // parent is not a directory
12740
+ // This is just to cause an internal ENOTDIR error to be thrown
12741
+ await fs$7.readdir(dir);
12742
+ }
12743
+ }
12744
+
12745
+ function createFileSync$1 (file) {
12746
+ let stats;
12747
+ try {
12748
+ stats = fs$7.statSync(file);
12749
+ } catch { }
12750
+ if (stats && stats.isFile()) return
12751
+
12752
+ const dir = path$6.dirname(file);
12753
+ try {
12754
+ if (!fs$7.statSync(dir).isDirectory()) {
12755
+ // parent is not a directory
12756
+ // This is just to cause an internal ENOTDIR error to be thrown
12757
+ fs$7.readdirSync(dir);
12758
+ }
12759
+ } catch (err) {
12760
+ // If the stat call above failed because the directory doesn't exist, create it
12761
+ if (err && err.code === 'ENOENT') mkdir$2.mkdirsSync(dir);
12762
+ else throw err
12763
+ }
12764
+
12765
+ fs$7.writeFileSync(file, '');
12766
+ }
12767
+
12768
+ var file = {
12769
+ createFile: u$7(createFile$1),
12770
+ createFileSync: createFileSync$1
12771
+ };
12772
+
12773
+ const u$6 = universalify$1.fromPromise;
12774
+ const path$5 = require$$1;
12775
+ const fs$6 = fs$h;
12776
+ const mkdir$1 = mkdirs$2;
12777
+ const { pathExists: pathExists$4 } = pathExists_1;
12778
+ const { areIdentical: areIdentical$1 } = stat$4;
12779
+
12780
+ async function createLink$1 (srcpath, dstpath) {
12781
+ let dstStat;
12782
+ try {
12783
+ dstStat = await fs$6.lstat(dstpath);
12784
+ } catch {
12785
+ // ignore error
12786
+ }
12787
+
12788
+ let srcStat;
12789
+ try {
12790
+ srcStat = await fs$6.lstat(srcpath);
12791
+ } catch (err) {
12792
+ err.message = err.message.replace('lstat', 'ensureLink');
12793
+ throw err
12794
+ }
12795
+
12796
+ if (dstStat && areIdentical$1(srcStat, dstStat)) return
12797
+
12798
+ const dir = path$5.dirname(dstpath);
12799
+
12800
+ const dirExists = await pathExists$4(dir);
12801
+
12802
+ if (!dirExists) {
12803
+ await mkdir$1.mkdirs(dir);
12804
+ }
12805
+
12806
+ await fs$6.link(srcpath, dstpath);
12807
+ }
12808
+
12809
+ function createLinkSync$1 (srcpath, dstpath) {
12810
+ let dstStat;
12811
+ try {
12812
+ dstStat = fs$6.lstatSync(dstpath);
12813
+ } catch {}
12814
+
12815
+ try {
12816
+ const srcStat = fs$6.lstatSync(srcpath);
12817
+ if (dstStat && areIdentical$1(srcStat, dstStat)) return
12818
+ } catch (err) {
12819
+ err.message = err.message.replace('lstat', 'ensureLink');
12820
+ throw err
12821
+ }
12822
+
12823
+ const dir = path$5.dirname(dstpath);
12824
+ const dirExists = fs$6.existsSync(dir);
12825
+ if (dirExists) return fs$6.linkSync(srcpath, dstpath)
12826
+ mkdir$1.mkdirsSync(dir);
12827
+
12828
+ return fs$6.linkSync(srcpath, dstpath)
12829
+ }
12830
+
12831
+ var link = {
12832
+ createLink: u$6(createLink$1),
12833
+ createLinkSync: createLinkSync$1
12834
+ };
12835
+
12836
+ const path$4 = require$$1;
12837
+ const fs$5 = fs$h;
12838
+ const { pathExists: pathExists$3 } = pathExists_1;
12839
+
12840
+ const u$5 = universalify$1.fromPromise;
12841
+
12842
+ /**
12843
+ * Function that returns two types of paths, one relative to symlink, and one
12844
+ * relative to the current working directory. Checks if path is absolute or
12845
+ * relative. If the path is relative, this function checks if the path is
12846
+ * relative to symlink or relative to current working directory. This is an
12847
+ * initiative to find a smarter `srcpath` to supply when building symlinks.
12848
+ * This allows you to determine which path to use out of one of three possible
12849
+ * types of source paths. The first is an absolute path. This is detected by
12850
+ * `path.isAbsolute()`. When an absolute path is provided, it is checked to
12851
+ * see if it exists. If it does it's used, if not an error is returned
12852
+ * (callback)/ thrown (sync). The other two options for `srcpath` are a
12853
+ * relative url. By default Node's `fs.symlink` works by creating a symlink
12854
+ * using `dstpath` and expects the `srcpath` to be relative to the newly
12855
+ * created symlink. If you provide a `srcpath` that does not exist on the file
12856
+ * system it results in a broken symlink. To minimize this, the function
12857
+ * checks to see if the 'relative to symlink' source file exists, and if it
12858
+ * does it will use it. If it does not, it checks if there's a file that
12859
+ * exists that is relative to the current working directory, if does its used.
12860
+ * This preserves the expectations of the original fs.symlink spec and adds
12861
+ * the ability to pass in `relative to current working direcotry` paths.
12862
+ */
12863
+
12864
+ async function symlinkPaths$1 (srcpath, dstpath) {
12865
+ if (path$4.isAbsolute(srcpath)) {
12866
+ try {
12867
+ await fs$5.lstat(srcpath);
12868
+ } catch (err) {
12869
+ err.message = err.message.replace('lstat', 'ensureSymlink');
12870
+ throw err
12871
+ }
12872
+
12873
+ return {
12874
+ toCwd: srcpath,
12875
+ toDst: srcpath
12876
+ }
12877
+ }
12878
+
12879
+ const dstdir = path$4.dirname(dstpath);
12880
+ const relativeToDst = path$4.join(dstdir, srcpath);
12881
+
12882
+ const exists = await pathExists$3(relativeToDst);
12883
+ if (exists) {
12884
+ return {
12885
+ toCwd: relativeToDst,
12886
+ toDst: srcpath
12887
+ }
12888
+ }
12889
+
12890
+ try {
12891
+ await fs$5.lstat(srcpath);
12892
+ } catch (err) {
12893
+ err.message = err.message.replace('lstat', 'ensureSymlink');
12894
+ throw err
12895
+ }
12896
+
12897
+ return {
12898
+ toCwd: srcpath,
12899
+ toDst: path$4.relative(dstdir, srcpath)
12900
+ }
12901
+ }
12902
+
12903
+ function symlinkPathsSync$1 (srcpath, dstpath) {
12904
+ if (path$4.isAbsolute(srcpath)) {
12905
+ const exists = fs$5.existsSync(srcpath);
12906
+ if (!exists) throw new Error('absolute srcpath does not exist')
12907
+ return {
12908
+ toCwd: srcpath,
12909
+ toDst: srcpath
12910
+ }
12911
+ }
12912
+
12913
+ const dstdir = path$4.dirname(dstpath);
12914
+ const relativeToDst = path$4.join(dstdir, srcpath);
12915
+ const exists = fs$5.existsSync(relativeToDst);
12916
+ if (exists) {
12917
+ return {
12918
+ toCwd: relativeToDst,
12919
+ toDst: srcpath
12920
+ }
12921
+ }
12922
+
12923
+ const srcExists = fs$5.existsSync(srcpath);
12924
+ if (!srcExists) throw new Error('relative srcpath does not exist')
12925
+ return {
12926
+ toCwd: srcpath,
12927
+ toDst: path$4.relative(dstdir, srcpath)
12928
+ }
12929
+ }
12930
+
12931
+ var symlinkPaths_1 = {
12932
+ symlinkPaths: u$5(symlinkPaths$1),
12933
+ symlinkPathsSync: symlinkPathsSync$1
12934
+ };
12935
+
12936
+ const fs$4 = fs$h;
12937
+ const u$4 = universalify$1.fromPromise;
12938
+
12939
+ async function symlinkType$1 (srcpath, type) {
12940
+ if (type) return type
12941
+
12942
+ let stats;
12943
+ try {
12944
+ stats = await fs$4.lstat(srcpath);
12945
+ } catch {
12946
+ return 'file'
12947
+ }
12948
+
12949
+ return (stats && stats.isDirectory()) ? 'dir' : 'file'
12950
+ }
12951
+
12952
+ function symlinkTypeSync$1 (srcpath, type) {
12953
+ if (type) return type
12954
+
12955
+ let stats;
12956
+ try {
12957
+ stats = fs$4.lstatSync(srcpath);
12958
+ } catch {
12959
+ return 'file'
12960
+ }
12961
+ return (stats && stats.isDirectory()) ? 'dir' : 'file'
12962
+ }
12963
+
12964
+ var symlinkType_1 = {
12965
+ symlinkType: u$4(symlinkType$1),
12966
+ symlinkTypeSync: symlinkTypeSync$1
12967
+ };
12968
+
12969
+ const u$3 = universalify$1.fromPromise;
12970
+ const path$3 = require$$1;
12971
+ const fs$3 = fs$h;
12972
+
12973
+ const { mkdirs, mkdirsSync } = mkdirs$2;
12974
+
12975
+ const { symlinkPaths, symlinkPathsSync } = symlinkPaths_1;
12976
+ const { symlinkType, symlinkTypeSync } = symlinkType_1;
12977
+
12978
+ const { pathExists: pathExists$2 } = pathExists_1;
12979
+
12980
+ const { areIdentical } = stat$4;
12981
+
12982
+ async function createSymlink$1 (srcpath, dstpath, type) {
12983
+ let stats;
12984
+ try {
12985
+ stats = await fs$3.lstat(dstpath);
12986
+ } catch { }
12987
+
12988
+ if (stats && stats.isSymbolicLink()) {
12989
+ const [srcStat, dstStat] = await Promise.all([
12990
+ fs$3.stat(srcpath),
12991
+ fs$3.stat(dstpath)
12992
+ ]);
12993
+
12994
+ if (areIdentical(srcStat, dstStat)) return
12995
+ }
12996
+
12997
+ const relative = await symlinkPaths(srcpath, dstpath);
12998
+ srcpath = relative.toDst;
12999
+ const toType = await symlinkType(relative.toCwd, type);
13000
+ const dir = path$3.dirname(dstpath);
13001
+
13002
+ if (!(await pathExists$2(dir))) {
13003
+ await mkdirs(dir);
13004
+ }
13005
+
13006
+ return fs$3.symlink(srcpath, dstpath, toType)
13007
+ }
13008
+
13009
+ function createSymlinkSync$1 (srcpath, dstpath, type) {
13010
+ let stats;
13011
+ try {
13012
+ stats = fs$3.lstatSync(dstpath);
13013
+ } catch { }
13014
+ if (stats && stats.isSymbolicLink()) {
13015
+ const srcStat = fs$3.statSync(srcpath);
13016
+ const dstStat = fs$3.statSync(dstpath);
13017
+ if (areIdentical(srcStat, dstStat)) return
13018
+ }
13019
+
13020
+ const relative = symlinkPathsSync(srcpath, dstpath);
13021
+ srcpath = relative.toDst;
13022
+ type = symlinkTypeSync(relative.toCwd, type);
13023
+ const dir = path$3.dirname(dstpath);
13024
+ const exists = fs$3.existsSync(dir);
13025
+ if (exists) return fs$3.symlinkSync(srcpath, dstpath, type)
13026
+ mkdirsSync(dir);
13027
+ return fs$3.symlinkSync(srcpath, dstpath, type)
13028
+ }
13029
+
13030
+ var symlink = {
13031
+ createSymlink: u$3(createSymlink$1),
13032
+ createSymlinkSync: createSymlinkSync$1
13033
+ };
13034
+
13035
+ const { createFile, createFileSync } = file;
13036
+ const { createLink, createLinkSync } = link;
13037
+ const { createSymlink, createSymlinkSync } = symlink;
13038
+
13039
+ var ensure = {
13040
+ // file
13041
+ createFile,
13042
+ createFileSync,
13043
+ ensureFile: createFile,
13044
+ ensureFileSync: createFileSync,
13045
+ // link
13046
+ createLink,
13047
+ createLinkSync,
13048
+ ensureLink: createLink,
13049
+ ensureLinkSync: createLinkSync,
13050
+ // symlink
13051
+ createSymlink,
13052
+ createSymlinkSync,
13053
+ ensureSymlink: createSymlink,
13054
+ ensureSymlinkSync: createSymlinkSync
13055
+ };
13056
+
13057
+ function stringify$3 (obj, { EOL = '\n', finalEOL = true, replacer = null, spaces } = {}) {
13058
+ const EOF = finalEOL ? EOL : '';
13059
+ const str = JSON.stringify(obj, replacer, spaces);
13060
+
13061
+ return str.replace(/\n/g, EOL) + EOF
13062
+ }
13063
+
13064
+ function stripBom$1 (content) {
13065
+ // we do this because JSON.parse would convert it to a utf8 string if encoding wasn't specified
13066
+ if (Buffer.isBuffer(content)) content = content.toString('utf8');
13067
+ return content.replace(/^\uFEFF/, '')
13068
+ }
13069
+
13070
+ var utils = { stringify: stringify$3, stripBom: stripBom$1 };
13071
+
13072
+ let _fs;
13073
+ try {
13074
+ _fs = gracefulFs;
13075
+ } catch (_) {
13076
+ _fs = require$$0$3;
13077
+ }
13078
+ const universalify = universalify$1;
13079
+ const { stringify: stringify$2, stripBom } = utils;
13080
+
13081
+ async function _readFile (file, options = {}) {
13082
+ if (typeof options === 'string') {
13083
+ options = { encoding: options };
13084
+ }
13085
+
13086
+ const fs = options.fs || _fs;
13087
+
13088
+ const shouldThrow = 'throws' in options ? options.throws : true;
13089
+
13090
+ let data = await universalify.fromCallback(fs.readFile)(file, options);
13091
+
13092
+ data = stripBom(data);
13093
+
13094
+ let obj;
13095
+ try {
13096
+ obj = JSON.parse(data, options ? options.reviver : null);
13097
+ } catch (err) {
13098
+ if (shouldThrow) {
13099
+ err.message = `${file}: ${err.message}`;
13100
+ throw err
13101
+ } else {
13102
+ return null
13103
+ }
13104
+ }
13105
+
13106
+ return obj
13107
+ }
13108
+
13109
+ const readFile = universalify.fromPromise(_readFile);
13110
+
13111
+ function readFileSync (file, options = {}) {
13112
+ if (typeof options === 'string') {
13113
+ options = { encoding: options };
13114
+ }
13115
+
13116
+ const fs = options.fs || _fs;
13117
+
13118
+ const shouldThrow = 'throws' in options ? options.throws : true;
13119
+
13120
+ try {
13121
+ let content = fs.readFileSync(file, options);
13122
+ content = stripBom(content);
13123
+ return JSON.parse(content, options.reviver)
13124
+ } catch (err) {
13125
+ if (shouldThrow) {
13126
+ err.message = `${file}: ${err.message}`;
13127
+ throw err
13128
+ } else {
13129
+ return null
13130
+ }
13131
+ }
13132
+ }
13133
+
13134
+ async function _writeFile (file, obj, options = {}) {
13135
+ const fs = options.fs || _fs;
13136
+
13137
+ const str = stringify$2(obj, options);
13138
+
13139
+ await universalify.fromCallback(fs.writeFile)(file, str, options);
13140
+ }
13141
+
13142
+ const writeFile = universalify.fromPromise(_writeFile);
13143
+
13144
+ function writeFileSync (file, obj, options = {}) {
13145
+ const fs = options.fs || _fs;
13146
+
13147
+ const str = stringify$2(obj, options);
13148
+ // not sure if fs.writeFileSync returns anything, but just in case
13149
+ return fs.writeFileSync(file, str, options)
13150
+ }
13151
+
13152
+ const jsonfile$1 = {
13153
+ readFile,
13154
+ readFileSync,
13155
+ writeFile,
13156
+ writeFileSync
13157
+ };
13158
+
13159
+ var jsonfile_1 = jsonfile$1;
13160
+
13161
+ const jsonFile$1 = jsonfile_1;
13162
+
13163
+ var jsonfile = {
13164
+ // jsonfile exports
13165
+ readJson: jsonFile$1.readFile,
13166
+ readJsonSync: jsonFile$1.readFileSync,
13167
+ writeJson: jsonFile$1.writeFile,
13168
+ writeJsonSync: jsonFile$1.writeFileSync
13169
+ };
13170
+
13171
+ const u$2 = universalify$1.fromPromise;
13172
+ const fs$2 = fs$h;
13173
+ const path$2 = require$$1;
13174
+ const mkdir = mkdirs$2;
13175
+ const pathExists$1 = pathExists_1.pathExists;
13176
+
13177
+ async function outputFile$1 (file, data, encoding = 'utf-8') {
13178
+ const dir = path$2.dirname(file);
13179
+
13180
+ if (!(await pathExists$1(dir))) {
13181
+ await mkdir.mkdirs(dir);
13182
+ }
13183
+
13184
+ return fs$2.writeFile(file, data, encoding)
13185
+ }
13186
+
13187
+ function outputFileSync$1 (file, ...args) {
13188
+ const dir = path$2.dirname(file);
13189
+ if (!fs$2.existsSync(dir)) {
13190
+ mkdir.mkdirsSync(dir);
13191
+ }
13192
+
13193
+ fs$2.writeFileSync(file, ...args);
13194
+ }
13195
+
13196
+ var outputFile_1 = {
13197
+ outputFile: u$2(outputFile$1),
13198
+ outputFileSync: outputFileSync$1
13199
+ };
13200
+
13201
+ const { stringify: stringify$1 } = utils;
13202
+ const { outputFile } = outputFile_1;
13203
+
13204
+ async function outputJson (file, data, options = {}) {
13205
+ const str = stringify$1(data, options);
13206
+
13207
+ await outputFile(file, str, options);
13208
+ }
13209
+
13210
+ var outputJson_1 = outputJson;
13211
+
13212
+ const { stringify } = utils;
13213
+ const { outputFileSync } = outputFile_1;
13214
+
13215
+ function outputJsonSync (file, data, options) {
13216
+ const str = stringify(data, options);
13217
+
13218
+ outputFileSync(file, str, options);
13219
+ }
13220
+
13221
+ var outputJsonSync_1 = outputJsonSync;
13222
+
13223
+ const u$1 = universalify$1.fromPromise;
13224
+ const jsonFile = jsonfile;
13225
+
13226
+ jsonFile.outputJson = u$1(outputJson_1);
13227
+ jsonFile.outputJsonSync = outputJsonSync_1;
13228
+ // aliases
13229
+ jsonFile.outputJSON = jsonFile.outputJson;
13230
+ jsonFile.outputJSONSync = jsonFile.outputJsonSync;
13231
+ jsonFile.writeJSON = jsonFile.writeJson;
13232
+ jsonFile.writeJSONSync = jsonFile.writeJsonSync;
13233
+ jsonFile.readJSON = jsonFile.readJson;
13234
+ jsonFile.readJSONSync = jsonFile.readJsonSync;
13235
+
13236
+ var json = jsonFile;
13237
+
13238
+ const fs$1 = fs$h;
13239
+ const path$1 = require$$1;
13240
+ const { copy } = copy$1;
13241
+ const { remove } = remove_1;
13242
+ const { mkdirp } = mkdirs$2;
13243
+ const { pathExists } = pathExists_1;
13244
+ const stat$1 = stat$4;
13245
+
13246
+ async function move$1 (src, dest, opts = {}) {
13247
+ const overwrite = opts.overwrite || opts.clobber || false;
13248
+
13249
+ const { srcStat, isChangingCase = false } = await stat$1.checkPaths(src, dest, 'move', opts);
13250
+
13251
+ await stat$1.checkParentPaths(src, srcStat, dest, 'move');
13252
+
13253
+ // If the parent of dest is not root, make sure it exists before proceeding
13254
+ const destParent = path$1.dirname(dest);
13255
+ const parsedParentPath = path$1.parse(destParent);
13256
+ if (parsedParentPath.root !== destParent) {
13257
+ await mkdirp(destParent);
13258
+ }
13259
+
13260
+ return doRename$1(src, dest, overwrite, isChangingCase)
13261
+ }
13262
+
13263
+ async function doRename$1 (src, dest, overwrite, isChangingCase) {
13264
+ if (!isChangingCase) {
13265
+ if (overwrite) {
13266
+ await remove(dest);
13267
+ } else if (await pathExists(dest)) {
13268
+ throw new Error('dest already exists.')
13269
+ }
13270
+ }
13271
+
13272
+ try {
13273
+ // Try w/ rename first, and try copy + remove if EXDEV
13274
+ await fs$1.rename(src, dest);
13275
+ } catch (err) {
13276
+ if (err.code !== 'EXDEV') {
13277
+ throw err
13278
+ }
13279
+ await moveAcrossDevice$1(src, dest, overwrite);
13280
+ }
13281
+ }
13282
+
13283
+ async function moveAcrossDevice$1 (src, dest, overwrite) {
13284
+ const opts = {
13285
+ overwrite,
13286
+ errorOnExist: true,
13287
+ preserveTimestamps: true
13288
+ };
13289
+
13290
+ await copy(src, dest, opts);
13291
+ return remove(src)
13292
+ }
13293
+
13294
+ var move_1 = move$1;
13295
+
13296
+ const fs = gracefulFs;
13297
+ const path = require$$1;
13298
+ const copySync = copy$1.copySync;
13299
+ const removeSync = remove_1.removeSync;
13300
+ const mkdirpSync = mkdirs$2.mkdirpSync;
13301
+ const stat = stat$4;
13302
+
13303
+ function moveSync (src, dest, opts) {
13304
+ opts = opts || {};
13305
+ const overwrite = opts.overwrite || opts.clobber || false;
13306
+
13307
+ const { srcStat, isChangingCase = false } = stat.checkPathsSync(src, dest, 'move', opts);
13308
+ stat.checkParentPathsSync(src, srcStat, dest, 'move');
13309
+ if (!isParentRoot(dest)) mkdirpSync(path.dirname(dest));
13310
+ return doRename(src, dest, overwrite, isChangingCase)
13311
+ }
13312
+
13313
+ function isParentRoot (dest) {
13314
+ const parent = path.dirname(dest);
13315
+ const parsedPath = path.parse(parent);
13316
+ return parsedPath.root === parent
13317
+ }
13318
+
13319
+ function doRename (src, dest, overwrite, isChangingCase) {
13320
+ if (isChangingCase) return rename(src, dest, overwrite)
13321
+ if (overwrite) {
13322
+ removeSync(dest);
13323
+ return rename(src, dest, overwrite)
13324
+ }
13325
+ if (fs.existsSync(dest)) throw new Error('dest already exists.')
13326
+ return rename(src, dest, overwrite)
13327
+ }
13328
+
13329
+ function rename (src, dest, overwrite) {
13330
+ try {
13331
+ fs.renameSync(src, dest);
13332
+ } catch (err) {
13333
+ if (err.code !== 'EXDEV') throw err
13334
+ return moveAcrossDevice(src, dest, overwrite)
13335
+ }
13336
+ }
13337
+
13338
+ function moveAcrossDevice (src, dest, overwrite) {
13339
+ const opts = {
13340
+ overwrite,
13341
+ errorOnExist: true,
13342
+ preserveTimestamps: true
13343
+ };
13344
+ copySync(src, dest, opts);
13345
+ return removeSync(src)
13346
+ }
13347
+
13348
+ var moveSync_1 = moveSync;
13349
+
13350
+ const u = universalify$1.fromPromise;
13351
+ var move = {
13352
+ move: u(move_1),
13353
+ moveSync: moveSync_1
13354
+ };
13355
+
13356
+ var lib = {
13357
+ // Export promiseified graceful-fs:
13358
+ ...fs$h,
13359
+ // Export extra methods:
13360
+ ...copy$1,
13361
+ ...empty,
13362
+ ...ensure,
13363
+ ...json,
13364
+ ...mkdirs$2,
13365
+ ...move,
13366
+ ...outputFile_1,
13367
+ ...pathExists_1,
13368
+ ...remove_1
13369
+ };
13370
+
13371
+ const emptyDirSessions = async (pathBase) => new Promise((resolve, reject) => {
13372
+ lib.emptyDir(pathBase, (err) => {
13373
+ if (err)
13374
+ reject(err);
13375
+ resolve(true);
13376
+ });
13377
+ });
10926
13378
  const venomCleanNumber = (number, full = false) => {
10927
13379
  number = number.replace('@c.us', '').replace('+', '').replace(/\s/g, '');
10928
13380
  number = !full ? `${number}@c.us` : `${number}`;
@@ -10930,7 +13382,7 @@ const venomCleanNumber = (number, full = false) => {
10930
13382
  };
10931
13383
  const writeFilePromise = (pathQr, response) => {
10932
13384
  return new Promise((resolve, reject) => {
10933
- fs.writeFile(pathQr, response.data, 'binary', (err) => {
13385
+ require$$0$3.writeFile(pathQr, response.data, 'binary', (err) => {
10934
13386
  if (err !== null)
10935
13387
  reject('ERROR_QR_GENERATE');
10936
13388
  resolve(true);
@@ -10956,7 +13408,7 @@ const venomGenerateImage = async (base, name = 'qr.png') => {
10956
13408
  const venomDeleteTokens = (session) => {
10957
13409
  try {
10958
13410
  const pathTokens = require$$1.join(process.cwd(), session);
10959
- fs.unlinkSync(pathTokens);
13411
+ emptyDirSessions(pathTokens);
10960
13412
  console.log('Tokens clean..');
10961
13413
  }
10962
13414
  catch (e) {
@@ -10987,7 +13439,7 @@ class VenomProvider extends bot.ProviderClass {
10987
13439
  this.indexHome = (req, res) => {
10988
13440
  const botName = req[this.idBotName];
10989
13441
  const qrPath = require$$1.join(process.cwd(), `${botName}.qr.png`);
10990
- const fileStream = fs.createReadStream(qrPath);
13442
+ const fileStream = require$$0$3.createReadStream(qrPath);
10991
13443
  res.writeHead(200, { 'Content-Type': 'image/png' });
10992
13444
  fileStream.pipe(res);
10993
13445
  };