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