rollup 2.7.2 → 2.7.6

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.
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.7.2
4
- Wed, 22 Apr 2020 19:00:15 GMT - commit 97e6fa89d2ad14603094af77bad461a1aa81df3b
3
+ Rollup.js v2.7.6
4
+ Thu, 30 Apr 2020 18:55:10 GMT - commit 468010ba801b1e59573b6aa7319461a449aa43df
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -11,7 +11,8 @@
11
11
  'use strict';
12
12
 
13
13
  var rollup_js = require('./rollup.js');
14
- var _util_commonjsExternal = require('./_util_commonjs-external.js');
14
+ var path = require('path');
15
+ var util = require('util');
15
16
  var fs = require('fs');
16
17
  var events = require('events');
17
18
  var stream = require('stream');
@@ -556,7 +557,7 @@ const toRegex = (start, end, options) => {
556
557
  };
557
558
 
558
559
  const rangeError = (...args) => {
559
- return new RangeError('Invalid range arguments: ' + _util_commonjsExternal.require$$1.inspect(...args));
560
+ return new RangeError('Invalid range arguments: ' + util.inspect(...args));
560
561
  };
561
562
 
562
563
  const invalidRange = (start, end, options) => {
@@ -1552,7 +1553,7 @@ var constants$1 = {
1552
1553
  CHAR_VERTICAL_LINE: 124, /* | */
1553
1554
  CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279, /* \uFEFF */
1554
1555
 
1555
- SEP: _util_commonjsExternal.sysPath.sep,
1556
+ SEP: path.sep,
1556
1557
 
1557
1558
  /**
1558
1559
  * Create EXTGLOB_CHARS
@@ -1612,7 +1613,7 @@ exports.isWindows = options => {
1612
1613
  if (options && typeof options.windows === 'boolean') {
1613
1614
  return options.windows;
1614
1615
  }
1615
- return win32 === true || _util_commonjsExternal.sysPath.sep === '\\';
1616
+ return win32 === true || path.sep === '\\';
1616
1617
  };
1617
1618
 
1618
1619
  exports.escapeLast = (input, char, lastIdx) => {
@@ -3246,7 +3247,7 @@ picomatch.test = (input, regex, options, { glob, posix } = {}) => {
3246
3247
 
3247
3248
  picomatch.matchBase = (input, glob, options, posix = utils$1.isWindows(options)) => {
3248
3249
  const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
3249
- return regex.test(_util_commonjsExternal.sysPath.basename(input));
3250
+ return regex.test(path.basename(input));
3250
3251
  };
3251
3252
 
3252
3253
  /**
@@ -3428,12 +3429,13 @@ var picomatch$1 = picomatch_1;
3428
3429
 
3429
3430
  const { Readable } = stream;
3430
3431
 
3431
- const { promisify } = _util_commonjsExternal.require$$1;
3432
+ const { promisify } = util;
3432
3433
 
3433
3434
 
3434
3435
  const readdir = promisify(fs.readdir);
3435
3436
  const stat = promisify(fs.stat);
3436
3437
  const lstat = promisify(fs.lstat);
3438
+ const realpath = promisify(fs.realpath);
3437
3439
 
3438
3440
  /**
3439
3441
  * @typedef {Object} EntryInfo
@@ -3525,17 +3527,13 @@ class ReaddirpStream extends Readable {
3525
3527
  this._wantsDir = [DIR_TYPE, FILE_DIR_TYPE, EVERYTHING_TYPE].includes(type);
3526
3528
  this._wantsFile = [FILE_TYPE, FILE_DIR_TYPE, EVERYTHING_TYPE].includes(type);
3527
3529
  this._wantsEverything = type === EVERYTHING_TYPE;
3528
- this._root = _util_commonjsExternal.sysPath.resolve(root);
3530
+ this._root = path.resolve(root);
3529
3531
  this._isDirent = ('Dirent' in fs) && !opts.alwaysStat;
3530
3532
  this._statsProp = this._isDirent ? 'dirent' : 'stats';
3531
3533
  this._rdOptions = { encoding: 'utf8', withFileTypes: this._isDirent };
3532
3534
 
3533
3535
  // Launch stream with one parent, the root dir.
3534
- try {
3535
- this.parents = [this._exploreDir(root, 1)];
3536
- } catch (error) {
3537
- this.destroy(error);
3538
- }
3536
+ this.parents = [this._exploreDir(root, 1)];
3539
3537
  this.reading = false;
3540
3538
  this.parent = undefined;
3541
3539
  }
@@ -3551,7 +3549,10 @@ class ReaddirpStream extends Readable {
3551
3549
  if (files.length > 0) {
3552
3550
  const slice = files.splice(0, batch).map(dirent => this._formatEntry(dirent, path));
3553
3551
  for (const entry of await Promise.all(slice)) {
3554
- if (this._isDirAndMatchesFilter(entry)) {
3552
+ if (this.destroyed) return;
3553
+
3554
+ const entryType = await this._getEntryType(entry);
3555
+ if (entryType === 'directory' && this._directoryFilter(entry)) {
3555
3556
  if (depth <= this._maxDepth) {
3556
3557
  this.parents.push(this._exploreDir(entry.fullPath, depth + 1));
3557
3558
  }
@@ -3560,7 +3561,7 @@ class ReaddirpStream extends Readable {
3560
3561
  this.push(entry);
3561
3562
  batch--;
3562
3563
  }
3563
- } else if (this._isFileAndMatchesFilter(entry)) {
3564
+ } else if ((entryType === 'file' || this._includeAsFile(entry)) && this._fileFilter(entry)) {
3564
3565
  if (this._wantsFile) {
3565
3566
  this.push(entry);
3566
3567
  batch--;
@@ -3574,6 +3575,7 @@ class ReaddirpStream extends Readable {
3574
3575
  break;
3575
3576
  }
3576
3577
  this.parent = await parent;
3578
+ if (this.destroyed) return;
3577
3579
  }
3578
3580
  }
3579
3581
  } catch (error) {
@@ -3593,11 +3595,12 @@ class ReaddirpStream extends Readable {
3593
3595
  return {files, depth, path};
3594
3596
  }
3595
3597
 
3596
- async _formatEntry(dirent, path) {
3597
- const basename = this._isDirent ? dirent.name : dirent;
3598
- const fullPath = _util_commonjsExternal.sysPath.resolve(_util_commonjsExternal.sysPath.join(path, basename));
3599
- const entry = {path: _util_commonjsExternal.sysPath.relative(this._root, fullPath), fullPath, basename};
3598
+ async _formatEntry(dirent, path$1) {
3599
+ let entry;
3600
3600
  try {
3601
+ const basename = this._isDirent ? dirent.name : dirent;
3602
+ const fullPath = path.resolve(path.join(path$1, basename));
3603
+ entry = {path: path.relative(this._root, fullPath), fullPath, basename};
3601
3604
  entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
3602
3605
  } catch (err) {
3603
3606
  this._onError(err);
@@ -3609,24 +3612,43 @@ class ReaddirpStream extends Readable {
3609
3612
  if (isNormalFlowError(err) && !this.destroyed) {
3610
3613
  this.emit('warn', err);
3611
3614
  } else {
3612
- throw err;
3615
+ this.destroy(err);
3613
3616
  }
3614
3617
  }
3615
3618
 
3616
- _isDirAndMatchesFilter(entry) {
3619
+ async _getEntryType(entry) {
3617
3620
  // entry may be undefined, because a warning or an error were emitted
3618
3621
  // and the statsProp is undefined
3619
3622
  const stats = entry && entry[this._statsProp];
3620
- return stats && stats.isDirectory() && this._directoryFilter(entry);
3623
+ if (!stats) {
3624
+ return;
3625
+ }
3626
+ if (stats.isFile()) {
3627
+ return 'file';
3628
+ }
3629
+ if (stats.isDirectory()) {
3630
+ return 'directory';
3631
+ }
3632
+ if (stats && stats.isSymbolicLink()) {
3633
+ try {
3634
+ const entryRealPath = await realpath(entry.fullPath);
3635
+ const entryRealPathStats = await lstat(entryRealPath);
3636
+ if (entryRealPathStats.isFile()) {
3637
+ return 'file';
3638
+ }
3639
+ if (entryRealPathStats.isDirectory()) {
3640
+ return 'directory';
3641
+ }
3642
+ } catch (error) {
3643
+ this._onError(error);
3644
+ }
3645
+ }
3621
3646
  }
3622
3647
 
3623
- _isFileAndMatchesFilter(entry) {
3648
+ _includeAsFile(entry) {
3624
3649
  const stats = entry && entry[this._statsProp];
3625
- const isFileType = stats && (
3626
- (this._wantsEverything && !stats.isDirectory()) ||
3627
- (stats.isFile() || stats.isSymbolicLink())
3628
- );
3629
- return isFileType && this._fileFilter(entry);
3650
+
3651
+ return stats && this._wantsEverything && !stats.isDirectory();
3630
3652
  }
3631
3653
  }
3632
3654
 
@@ -3890,7 +3912,7 @@ var isGlob = function isGlob(str, options) {
3890
3912
  return false;
3891
3913
  };
3892
3914
 
3893
- var pathPosixDirname = _util_commonjsExternal.sysPath.posix.dirname;
3915
+ var pathPosixDirname = path.posix.dirname;
3894
3916
  var isWin32 = os.platform() === 'win32';
3895
3917
 
3896
3918
  var slash = '/';
@@ -4193,11 +4215,11 @@ var binaryExtensions$2 = require$$0;
4193
4215
 
4194
4216
  const extensions = new Set(binaryExtensions$2);
4195
4217
 
4196
- var isBinaryPath = filePath => extensions.has(_util_commonjsExternal.sysPath.extname(filePath).slice(1).toLowerCase());
4218
+ var isBinaryPath = filePath => extensions.has(path.extname(filePath).slice(1).toLowerCase());
4197
4219
 
4198
4220
  var constants$2 = rollup_js.createCommonjsModule(function (module, exports) {
4199
4221
 
4200
- const {sep} = _util_commonjsExternal.sysPath;
4222
+ const {sep} = path;
4201
4223
  const {platform} = process;
4202
4224
 
4203
4225
  exports.EV_ALL = 'all';
@@ -4220,6 +4242,7 @@ exports.FSEVENT_DELETED = 'deleted';
4220
4242
  exports.FSEVENT_MOVED = 'moved';
4221
4243
  exports.FSEVENT_CLONED = 'cloned';
4222
4244
  exports.FSEVENT_UNKNOWN = 'unknown';
4245
+ exports.FSEVENT_TYPE_FILE = 'file';
4223
4246
  exports.FSEVENT_TYPE_DIRECTORY = 'directory';
4224
4247
  exports.FSEVENT_TYPE_SYMLINK = 'symlink';
4225
4248
 
@@ -4257,7 +4280,7 @@ exports.isWindows = platform === 'win32';
4257
4280
  exports.isMacos = platform === 'darwin';
4258
4281
  });
4259
4282
 
4260
- const { promisify: promisify$1 } = _util_commonjsExternal.require$$1;
4283
+ const { promisify: promisify$1 } = util;
4261
4284
 
4262
4285
  const {
4263
4286
  isWindows,
@@ -4356,21 +4379,21 @@ const FsWatchInstances = new Map();
4356
4379
  * @param {Function} emitRaw emits raw event data
4357
4380
  * @returns {fs.FSWatcher} new fsevents instance
4358
4381
  */
4359
- function createFsWatchInstance(path, options, listener, errHandler, emitRaw) {
4382
+ function createFsWatchInstance(path$1, options, listener, errHandler, emitRaw) {
4360
4383
  const handleEvent = (rawEvent, evPath) => {
4361
- listener(path);
4362
- emitRaw(rawEvent, evPath, {watchedPath: path});
4384
+ listener(path$1);
4385
+ emitRaw(rawEvent, evPath, {watchedPath: path$1});
4363
4386
 
4364
4387
  // emit based on events occurring for files from a directory's watcher in
4365
4388
  // case the file's watcher misses it (and rely on throttling to de-dupe)
4366
- if (evPath && path !== evPath) {
4389
+ if (evPath && path$1 !== evPath) {
4367
4390
  fsWatchBroadcast(
4368
- _util_commonjsExternal.sysPath.resolve(path, evPath), KEY_LISTENERS, _util_commonjsExternal.sysPath.join(path, evPath)
4391
+ path.resolve(path$1, evPath), KEY_LISTENERS, path.join(path$1, evPath)
4369
4392
  );
4370
4393
  }
4371
4394
  };
4372
4395
  try {
4373
- return fs.watch(path, options, handleEvent);
4396
+ return fs.watch(path$1, options, handleEvent);
4374
4397
  } catch (error) {
4375
4398
  errHandler(error);
4376
4399
  }
@@ -4553,13 +4576,13 @@ constructor(fsW) {
4553
4576
  * @param {Function} listener on fs change
4554
4577
  * @returns {Function} closer for the watcher instance
4555
4578
  */
4556
- _watchWithNodeFs(path, listener) {
4579
+ _watchWithNodeFs(path$1, listener) {
4557
4580
  const opts = this.fsw.options;
4558
- const directory = _util_commonjsExternal.sysPath.dirname(path);
4559
- const basename = _util_commonjsExternal.sysPath.basename(path);
4581
+ const directory = path.dirname(path$1);
4582
+ const basename = path.basename(path$1);
4560
4583
  const parent = this.fsw._getWatchedDir(directory);
4561
4584
  parent.add(basename);
4562
- const absolutePath = _util_commonjsExternal.sysPath.resolve(path);
4585
+ const absolutePath = path.resolve(path$1);
4563
4586
  const options = {persistent: opts.persistent};
4564
4587
  if (!listener) listener = EMPTY_FN;
4565
4588
 
@@ -4567,12 +4590,12 @@ _watchWithNodeFs(path, listener) {
4567
4590
  if (opts.usePolling) {
4568
4591
  options.interval = opts.enableBinaryInterval && isBinaryPath(basename) ?
4569
4592
  opts.binaryInterval : opts.interval;
4570
- closer = setFsWatchFileListener(path, absolutePath, options, {
4593
+ closer = setFsWatchFileListener(path$1, absolutePath, options, {
4571
4594
  listener,
4572
4595
  rawEmitter: this.fsw._emitRaw
4573
4596
  });
4574
4597
  } else {
4575
- closer = setFsWatchListener(path, absolutePath, options, {
4598
+ closer = setFsWatchListener(path$1, absolutePath, options, {
4576
4599
  listener,
4577
4600
  errHandler: this._boundHandleError,
4578
4601
  rawEmitter: this.fsw._emitRaw
@@ -4592,8 +4615,8 @@ _handleFile(file, stats, initialAdd) {
4592
4615
  if (this.fsw.closed) {
4593
4616
  return;
4594
4617
  }
4595
- const dirname = _util_commonjsExternal.sysPath.dirname(file);
4596
- const basename = _util_commonjsExternal.sysPath.basename(file);
4618
+ const dirname = path.dirname(file);
4619
+ const basename = path.basename(file);
4597
4620
  const parent = this.fsw._getWatchedDir(dirname);
4598
4621
  // stats is always present
4599
4622
  let prevStats = stats;
@@ -4684,7 +4707,7 @@ async _handleSymlink(entry, directory, path, item) {
4684
4707
 
4685
4708
  _handleRead(directory, initialAdd, wh, target, dir, depth, throttler) {
4686
4709
  // Normalize the directory name on Windows
4687
- directory = _util_commonjsExternal.sysPath.join(directory, EMPTY_STR);
4710
+ directory = path.join(directory, EMPTY_STR);
4688
4711
 
4689
4712
  if (!wh.hasGlob) {
4690
4713
  throttler = this.fsw._throttle('readdir', directory, 1000);
@@ -4704,10 +4727,10 @@ _handleRead(directory, initialAdd, wh, target, dir, depth, throttler) {
4704
4727
  return;
4705
4728
  }
4706
4729
  const item = entry.path;
4707
- let path = _util_commonjsExternal.sysPath.join(directory, item);
4730
+ let path$1 = path.join(directory, item);
4708
4731
  current.add(item);
4709
4732
 
4710
- if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path, item)) {
4733
+ if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path$1, item)) {
4711
4734
  return;
4712
4735
  }
4713
4736
 
@@ -4722,9 +4745,9 @@ _handleRead(directory, initialAdd, wh, target, dir, depth, throttler) {
4722
4745
  this.fsw._incrReadyCount();
4723
4746
 
4724
4747
  // ensure relativeness of path is preserved in case of watcher reuse
4725
- path = _util_commonjsExternal.sysPath.join(dir, _util_commonjsExternal.sysPath.relative(dir, path));
4748
+ path$1 = path.join(dir, path.relative(dir, path$1));
4726
4749
 
4727
- this._addToNodeFs(path, initialAdd, wh, depth + 1);
4750
+ this._addToNodeFs(path$1, initialAdd, wh, depth + 1);
4728
4751
  }
4729
4752
  }).on(EV_ERROR, this._boundHandleError);
4730
4753
 
@@ -4748,7 +4771,7 @@ _handleRead(directory, initialAdd, wh, target, dir, depth, throttler) {
4748
4771
  // a path may have been filtered out of this readdir, but
4749
4772
  // shouldn't be removed because it matches a different glob
4750
4773
  (!wh.hasGlob || wh.filterPath({
4751
- fullPath: _util_commonjsExternal.sysPath.resolve(directory, item)
4774
+ fullPath: path.resolve(directory, item)
4752
4775
  }));
4753
4776
  }).forEach((item) => {
4754
4777
  this.fsw._remove(directory, item);
@@ -4774,14 +4797,14 @@ _handleRead(directory, initialAdd, wh, target, dir, depth, throttler) {
4774
4797
  * @returns {Promise<Function>} closer for the watcher instance.
4775
4798
  */
4776
4799
  async _handleDir(dir, stats, initialAdd, depth, target, wh, realpath) {
4777
- const parentDir = this.fsw._getWatchedDir(_util_commonjsExternal.sysPath.dirname(dir));
4778
- const tracked = parentDir.has(_util_commonjsExternal.sysPath.basename(dir));
4800
+ const parentDir = this.fsw._getWatchedDir(path.dirname(dir));
4801
+ const tracked = parentDir.has(path.basename(dir));
4779
4802
  if (!(initialAdd && this.fsw.options.ignoreInitial) && !target && !tracked) {
4780
4803
  if (!wh.hasGlob || wh.globFilter(dir)) this.fsw._emit(EV_ADD_DIR, dir, stats);
4781
4804
  }
4782
4805
 
4783
4806
  // ensure dir is tracked (harmless if redundant)
4784
- parentDir.add(_util_commonjsExternal.sysPath.basename(dir));
4807
+ parentDir.add(path.basename(dir));
4785
4808
  this.fsw._getWatchedDir(dir);
4786
4809
  let throttler;
4787
4810
  let closer;
@@ -4813,14 +4836,14 @@ async _handleDir(dir, stats, initialAdd, depth, target, wh, realpath) {
4813
4836
  * @param {String=} target Child path actually targeted for watch
4814
4837
  * @returns {Promise}
4815
4838
  */
4816
- async _addToNodeFs(path, initialAdd, priorWh, depth, target) {
4839
+ async _addToNodeFs(path$1, initialAdd, priorWh, depth, target) {
4817
4840
  const ready = this.fsw._emitReady;
4818
- if (this.fsw._isIgnored(path) || this.fsw.closed) {
4841
+ if (this.fsw._isIgnored(path$1) || this.fsw.closed) {
4819
4842
  ready();
4820
4843
  return false;
4821
4844
  }
4822
4845
 
4823
- const wh = this.fsw._getWatchHelpers(path, depth);
4846
+ const wh = this.fsw._getWatchHelpers(path$1, depth);
4824
4847
  if (!wh.hasGlob && priorWh) {
4825
4848
  wh.hasGlob = priorWh.hasGlob;
4826
4849
  wh.globFilter = priorWh.globFilter;
@@ -4837,42 +4860,42 @@ async _addToNodeFs(path, initialAdd, priorWh, depth, target) {
4837
4860
  return false;
4838
4861
  }
4839
4862
 
4840
- const follow = this.fsw.options.followSymlinks && !path.includes(STAR$1) && !path.includes(BRACE_START);
4863
+ const follow = this.fsw.options.followSymlinks && !path$1.includes(STAR$1) && !path$1.includes(BRACE_START);
4841
4864
  let closer;
4842
4865
  if (stats.isDirectory()) {
4843
- const targetPath = follow ? await fsrealpath(path) : path;
4866
+ const targetPath = follow ? await fsrealpath(path$1) : path$1;
4844
4867
  if (this.fsw.closed) return;
4845
4868
  closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
4846
4869
  if (this.fsw.closed) return;
4847
4870
  // preserve this symlink's target path
4848
- if (path !== targetPath && targetPath !== undefined) {
4871
+ if (path$1 !== targetPath && targetPath !== undefined) {
4849
4872
  this.fsw._symlinkPaths.set(targetPath, true);
4850
4873
  }
4851
4874
  } else if (stats.isSymbolicLink()) {
4852
- const targetPath = follow ? await fsrealpath(path) : path;
4875
+ const targetPath = follow ? await fsrealpath(path$1) : path$1;
4853
4876
  if (this.fsw.closed) return;
4854
- const parent = _util_commonjsExternal.sysPath.dirname(wh.watchPath);
4877
+ const parent = path.dirname(wh.watchPath);
4855
4878
  this.fsw._getWatchedDir(parent).add(wh.watchPath);
4856
4879
  this.fsw._emit(EV_ADD, wh.watchPath, stats);
4857
- closer = await this._handleDir(parent, stats, initialAdd, depth, path, wh, targetPath);
4880
+ closer = await this._handleDir(parent, stats, initialAdd, depth, path$1, wh, targetPath);
4858
4881
  if (this.fsw.closed) return;
4859
4882
 
4860
4883
  // preserve this symlink's target path
4861
4884
  if (targetPath !== undefined) {
4862
- this.fsw._symlinkPaths.set(_util_commonjsExternal.sysPath.resolve(path), targetPath);
4885
+ this.fsw._symlinkPaths.set(path.resolve(path$1), targetPath);
4863
4886
  }
4864
4887
  } else {
4865
4888
  closer = this._handleFile(wh.watchPath, stats, initialAdd);
4866
4889
  }
4867
4890
  ready();
4868
4891
 
4869
- this.fsw._addPathCloser(path, closer);
4892
+ this.fsw._addPathCloser(path$1, closer);
4870
4893
  return false;
4871
4894
 
4872
4895
  } catch (error) {
4873
4896
  if (this.fsw._handleError(error)) {
4874
4897
  ready();
4875
- return path;
4898
+ return path$1;
4876
4899
  }
4877
4900
  }
4878
4901
  }
@@ -4883,7 +4906,7 @@ var nodefsHandler = NodeFsHandler;
4883
4906
 
4884
4907
  var require$$1 = rollup_js.getCjsExportFromNamespace(rollup_js.fseventsImporter);
4885
4908
 
4886
- const { promisify: promisify$2 } = _util_commonjsExternal.require$$1;
4909
+ const { promisify: promisify$2 } = util;
4887
4910
 
4888
4911
  let fsevents;
4889
4912
  try {
@@ -4918,6 +4941,7 @@ const {
4918
4941
  FSEVENT_MOVED,
4919
4942
  // FSEVENT_CLONED,
4920
4943
  FSEVENT_UNKNOWN,
4944
+ FSEVENT_TYPE_FILE,
4921
4945
  FSEVENT_TYPE_DIRECTORY,
4922
4946
  FSEVENT_TYPE_SYMLINK,
4923
4947
 
@@ -4928,15 +4952,12 @@ const {
4928
4952
  EMPTY_FN: EMPTY_FN$1,
4929
4953
  IDENTITY_FN
4930
4954
  } = constants$2;
4931
- const FS_MODE_READ = 'r';
4932
4955
 
4933
4956
  const Depth = (value) => isNaN(value) ? {} : {depth: value};
4934
4957
 
4935
4958
  const stat$2 = promisify$2(fs.stat);
4936
- const open$1 = promisify$2(fs.open);
4937
- const close$1 = promisify$2(fs.close);
4938
4959
  const lstat$2 = promisify$2(fs.lstat);
4939
- const realpath = promisify$2(fs.realpath);
4960
+ const realpath$1 = promisify$2(fs.realpath);
4940
4961
 
4941
4962
  const statMethods$1 = { stat: stat$2, lstat: lstat$2 };
4942
4963
 
@@ -4986,9 +5007,9 @@ const createFSEventsInstance = (path, callback) => {
4986
5007
  * @param {Function} rawEmitter - passes data to listeners of the 'raw' event
4987
5008
  * @returns {Function} closer
4988
5009
  */
4989
- function setFSEventsListener(path, realPath, listener, rawEmitter, fsw) {
4990
- let watchPath = _util_commonjsExternal.sysPath.extname(path) ? _util_commonjsExternal.sysPath.dirname(path) : path;
4991
- const parentPath = _util_commonjsExternal.sysPath.dirname(watchPath);
5010
+ function setFSEventsListener(path$1, realPath, listener, rawEmitter, fsw) {
5011
+ let watchPath = path.extname(path$1) ? path.dirname(path$1) : path$1;
5012
+ const parentPath = path.dirname(watchPath);
4992
5013
  let cont = FSEventsWatchers.get(watchPath);
4993
5014
 
4994
5015
  // If we've accumulated a substantial number of paths that
@@ -4999,14 +5020,14 @@ function setFSEventsListener(path, realPath, listener, rawEmitter, fsw) {
4999
5020
  watchPath = parentPath;
5000
5021
  }
5001
5022
 
5002
- const resolvedPath = _util_commonjsExternal.sysPath.resolve(path);
5023
+ const resolvedPath = path.resolve(path$1);
5003
5024
  const hasSymlink = resolvedPath !== realPath;
5004
5025
 
5005
5026
  const filteredListener = (fullPath, flags, info) => {
5006
5027
  if (hasSymlink) fullPath = fullPath.replace(realPath, resolvedPath);
5007
5028
  if (
5008
5029
  fullPath === resolvedPath ||
5009
- !fullPath.indexOf(resolvedPath + _util_commonjsExternal.sysPath.sep)
5030
+ !fullPath.indexOf(resolvedPath + path.sep)
5010
5031
  ) listener(fullPath, flags, info);
5011
5032
  };
5012
5033
 
@@ -5014,7 +5035,7 @@ function setFSEventsListener(path, realPath, listener, rawEmitter, fsw) {
5014
5035
  // modifies `watchPath` to the parent path when it finds a match
5015
5036
  let watchedParent = false;
5016
5037
  for (const watchedPath of FSEventsWatchers.keys()) {
5017
- if (realPath.indexOf(_util_commonjsExternal.sysPath.resolve(watchedPath) + _util_commonjsExternal.sysPath.sep) === 0) {
5038
+ if (realPath.indexOf(path.resolve(watchedPath) + path.sep) === 0) {
5018
5039
  watchPath = watchedPath;
5019
5040
  cont = FSEventsWatchers.get(watchPath);
5020
5041
  watchedParent = true;
@@ -5077,12 +5098,20 @@ const couldConsolidate = (path) => {
5077
5098
  const canUse = () => fsevents && FSEventsWatchers.size < 128;
5078
5099
 
5079
5100
  // determines subdirectory traversal levels from root to path
5080
- const calcDepth = (path, root) => {
5101
+ const calcDepth = (path$1, root) => {
5081
5102
  let i = 0;
5082
- while (!path.indexOf(root) && (path = _util_commonjsExternal.sysPath.dirname(path)) !== root) i++;
5103
+ while (!path$1.indexOf(root) && (path$1 = path.dirname(path$1)) !== root) i++;
5083
5104
  return i;
5084
5105
  };
5085
5106
 
5107
+ // returns boolean indicating whether the fsevents' event info has the same type
5108
+ // as the one returned by fs.stat
5109
+ const sameTypes = (info, stats) => (
5110
+ info.type === FSEVENT_TYPE_DIRECTORY && stats.isDirectory() ||
5111
+ info.type === FSEVENT_TYPE_SYMLINK && stats.isSymbolicLink() ||
5112
+ info.type === FSEVENT_TYPE_FILE && stats.isFile()
5113
+ );
5114
+
5086
5115
  /**
5087
5116
  * @mixin
5088
5117
  */
@@ -5113,13 +5142,16 @@ addOrChange(path, fullPath, realPath, parent, watchedDir, item, info, opts) {
5113
5142
  this.handleEvent(event, path, fullPath, realPath, parent, watchedDir, item, info, opts);
5114
5143
  }
5115
5144
 
5116
- async checkFd(path, fullPath, realPath, parent, watchedDir, item, info, opts) {
5145
+ async checkExists(path, fullPath, realPath, parent, watchedDir, item, info, opts) {
5117
5146
  try {
5118
- const fd = await open$1(path, FS_MODE_READ);
5147
+ const stats = await stat$2(path);
5119
5148
  if (this.fsw.closed) return;
5120
- await close$1(fd);
5121
5149
  if (this.fsw.closed) return;
5122
- this.addOrChange(path, fullPath, realPath, parent, watchedDir, item, info, opts);
5150
+ if (sameTypes(info, stats)) {
5151
+ this.addOrChange(path, fullPath, realPath, parent, watchedDir, item, info, opts);
5152
+ } else {
5153
+ this.handleEvent(EV_UNLINK, path, fullPath, realPath, parent, watchedDir, item, info, opts);
5154
+ }
5123
5155
  } catch (error) {
5124
5156
  if (error.code === 'EACCES') {
5125
5157
  this.addOrChange(path, fullPath, realPath, parent, watchedDir, item, info, opts);
@@ -5133,9 +5165,10 @@ handleEvent(event, path, fullPath, realPath, parent, watchedDir, item, info, opt
5133
5165
  if (this.fsw.closed || this.checkIgnored(path)) return;
5134
5166
 
5135
5167
  if (event === EV_UNLINK) {
5168
+ const isDirectory = info.type === FSEVENT_TYPE_DIRECTORY;
5136
5169
  // suppress unlink events on never before seen files
5137
- if (info.type === FSEVENT_TYPE_DIRECTORY || watchedDir.has(item)) {
5138
- this.fsw._remove(parent, item);
5170
+ if (isDirectory || watchedDir.has(item)) {
5171
+ this.fsw._remove(parent, item, isDirectory);
5139
5172
  }
5140
5173
  } else {
5141
5174
  if (event === EV_ADD$1) {
@@ -5180,15 +5213,15 @@ _watchWithFsEvents(watchPath, realPath, transform, globFilter) {
5180
5213
  opts.depth !== undefined &&
5181
5214
  calcDepth(fullPath, realPath) > opts.depth
5182
5215
  ) return;
5183
- const path = transform(_util_commonjsExternal.sysPath.join(
5184
- watchPath, _util_commonjsExternal.sysPath.relative(watchPath, fullPath)
5216
+ const path$1 = transform(path.join(
5217
+ watchPath, path.relative(watchPath, fullPath)
5185
5218
  ));
5186
- if (globFilter && !globFilter(path)) return;
5219
+ if (globFilter && !globFilter(path$1)) return;
5187
5220
  // ensure directories are tracked
5188
- const parent = _util_commonjsExternal.sysPath.dirname(path);
5189
- const item = _util_commonjsExternal.sysPath.basename(path);
5221
+ const parent = path.dirname(path$1);
5222
+ const item = path.basename(path$1);
5190
5223
  const watchedDir = this.fsw._getWatchedDir(
5191
- info.type === FSEVENT_TYPE_DIRECTORY ? path : parent
5224
+ info.type === FSEVENT_TYPE_DIRECTORY ? path$1 : parent
5192
5225
  );
5193
5226
 
5194
5227
  // correct for wrong events emitted
@@ -5196,26 +5229,26 @@ _watchWithFsEvents(watchPath, realPath, transform, globFilter) {
5196
5229
  if (typeof opts.ignored === FUNCTION_TYPE) {
5197
5230
  let stats;
5198
5231
  try {
5199
- stats = await stat$2(path);
5232
+ stats = await stat$2(path$1);
5200
5233
  } catch (error) {}
5201
5234
  if (this.fsw.closed) return;
5202
- if (this.checkIgnored(path, stats)) return;
5203
- if (stats) {
5204
- this.addOrChange(path, fullPath, realPath, parent, watchedDir, item, info, opts);
5235
+ if (this.checkIgnored(path$1, stats)) return;
5236
+ if (sameTypes(info, stats)) {
5237
+ this.addOrChange(path$1, fullPath, realPath, parent, watchedDir, item, info, opts);
5205
5238
  } else {
5206
- this.handleEvent(EV_UNLINK, path, fullPath, realPath, parent, watchedDir, item, info, opts);
5239
+ this.handleEvent(EV_UNLINK, path$1, fullPath, realPath, parent, watchedDir, item, info, opts);
5207
5240
  }
5208
5241
  } else {
5209
- this.checkFd(path, fullPath, realPath, parent, watchedDir, item, info, opts);
5242
+ this.checkExists(path$1, fullPath, realPath, parent, watchedDir, item, info, opts);
5210
5243
  }
5211
5244
  } else {
5212
5245
  switch (info.event) {
5213
5246
  case FSEVENT_CREATED:
5214
5247
  case FSEVENT_MODIFIED:
5215
- return this.addOrChange(path, fullPath, realPath, parent, watchedDir, item, info, opts);
5248
+ return this.addOrChange(path$1, fullPath, realPath, parent, watchedDir, item, info, opts);
5216
5249
  case FSEVENT_DELETED:
5217
5250
  case FSEVENT_MOVED:
5218
- return this.checkFd(path, fullPath, realPath, parent, watchedDir, item, info, opts);
5251
+ return this.checkExists(path$1, fullPath, realPath, parent, watchedDir, item, info, opts);
5219
5252
  }
5220
5253
  }
5221
5254
  };
@@ -5248,7 +5281,7 @@ async _handleFsEventsSymlink(linkPath, fullPath, transform, curDepth) {
5248
5281
  this.fsw._incrReadyCount();
5249
5282
 
5250
5283
  try {
5251
- const linkTarget = await realpath(linkPath);
5284
+ const linkTarget = await realpath$1(linkPath);
5252
5285
  if (this.fsw.closed) return;
5253
5286
  if (this.fsw._isIgnored(linkTarget)) {
5254
5287
  return this.fsw._emitReady();
@@ -5258,12 +5291,12 @@ async _handleFsEventsSymlink(linkPath, fullPath, transform, curDepth) {
5258
5291
 
5259
5292
  // add the linkTarget for watching with a wrapper for transform
5260
5293
  // that causes emitted paths to incorporate the link's path
5261
- this._addToFsEvents(linkTarget || linkPath, (path) => {
5294
+ this._addToFsEvents(linkTarget || linkPath, (path$1) => {
5262
5295
  let aliasedPath = linkPath;
5263
5296
  if (linkTarget && linkTarget !== DOT_SLASH) {
5264
- aliasedPath = path.replace(linkTarget, linkPath);
5265
- } else if (path !== DOT_SLASH) {
5266
- aliasedPath = _util_commonjsExternal.sysPath.join(linkPath, path);
5297
+ aliasedPath = path$1.replace(linkTarget, linkPath);
5298
+ } else if (path$1 !== DOT_SLASH) {
5299
+ aliasedPath = path.join(linkPath, path$1);
5267
5300
  }
5268
5301
  return transform(aliasedPath);
5269
5302
  }, false, curDepth);
@@ -5282,8 +5315,8 @@ async _handleFsEventsSymlink(linkPath, fullPath, transform, curDepth) {
5282
5315
  emitAdd(newPath, stats, processPath, opts, forceAdd) {
5283
5316
  const pp = processPath(newPath);
5284
5317
  const isDir = stats.isDirectory();
5285
- const dirObj = this.fsw._getWatchedDir(_util_commonjsExternal.sysPath.dirname(pp));
5286
- const base = _util_commonjsExternal.sysPath.basename(pp);
5318
+ const dirObj = this.fsw._getWatchedDir(path.dirname(pp));
5319
+ const base = path.basename(pp);
5287
5320
 
5288
5321
  // ensure empty dirs get tracked
5289
5322
  if (isDir) this.fsw._getWatchedDir(pp);
@@ -5295,15 +5328,15 @@ emitAdd(newPath, stats, processPath, opts, forceAdd) {
5295
5328
  }
5296
5329
  }
5297
5330
 
5298
- initWatch(realPath, path, wh, processPath) {
5331
+ initWatch(realPath, path$1, wh, processPath) {
5299
5332
  if (this.fsw.closed) return;
5300
5333
  const closer = this._watchWithFsEvents(
5301
5334
  wh.watchPath,
5302
- _util_commonjsExternal.sysPath.resolve(realPath || wh.watchPath),
5335
+ path.resolve(realPath || wh.watchPath),
5303
5336
  processPath,
5304
5337
  wh.globFilter
5305
5338
  );
5306
- this.fsw._addPathCloser(path, closer);
5339
+ this.fsw._addPathCloser(path$1, closer);
5307
5340
  }
5308
5341
 
5309
5342
  /**
@@ -5314,14 +5347,14 @@ initWatch(realPath, path, wh, processPath) {
5314
5347
  * @param {Number=} priorDepth Level of subdirectories already traversed.
5315
5348
  * @returns {Promise<void>}
5316
5349
  */
5317
- async _addToFsEvents(path, transform, forceAdd, priorDepth) {
5350
+ async _addToFsEvents(path$1, transform, forceAdd, priorDepth) {
5318
5351
  if (this.fsw.closed) {
5319
5352
  return;
5320
5353
  }
5321
5354
  const opts = this.fsw.options;
5322
5355
  const processPath = typeof transform === FUNCTION_TYPE ? transform : IDENTITY_FN;
5323
5356
 
5324
- const wh = this.fsw._getWatchHelpers(path);
5357
+ const wh = this.fsw._getWatchHelpers(path$1);
5325
5358
 
5326
5359
  // evaluate what is at the path we're being asked to watch
5327
5360
  try {
@@ -5332,7 +5365,7 @@ async _addToFsEvents(path, transform, forceAdd, priorDepth) {
5332
5365
  }
5333
5366
  if (stats.isDirectory()) {
5334
5367
  // emit addDir unless this is a glob parent
5335
- if (!wh.globFilter) this.emitAdd(processPath(path), stats, processPath, opts, forceAdd);
5368
+ if (!wh.globFilter) this.emitAdd(processPath(path$1), stats, processPath, opts, forceAdd);
5336
5369
 
5337
5370
  // don't recurse further if it would exceed depth setting
5338
5371
  if (priorDepth && priorDepth > opts.depth) return;
@@ -5349,14 +5382,14 @@ async _addToFsEvents(path, transform, forceAdd, priorDepth) {
5349
5382
  }
5350
5383
  if (entry.stats.isDirectory() && !wh.filterPath(entry)) return;
5351
5384
 
5352
- const joinedPath = _util_commonjsExternal.sysPath.join(wh.watchPath, entry.path);
5385
+ const joinedPath = path.join(wh.watchPath, entry.path);
5353
5386
  const {fullPath} = entry;
5354
5387
 
5355
5388
  if (wh.followSymlinks && entry.stats.isSymbolicLink()) {
5356
5389
  // preserve the current depth here since it can't be derived from
5357
5390
  // real paths past the symlink
5358
5391
  const curDepth = opts.depth === undefined ?
5359
- undefined : calcDepth(joinedPath, _util_commonjsExternal.sysPath.resolve(wh.watchPath)) + 1;
5392
+ undefined : calcDepth(joinedPath, path.resolve(wh.watchPath)) + 1;
5360
5393
 
5361
5394
  this._handleFsEventsSymlink(joinedPath, fullPath, processPath, curDepth);
5362
5395
  } else {
@@ -5380,13 +5413,13 @@ async _addToFsEvents(path, transform, forceAdd, priorDepth) {
5380
5413
  if (opts.persistent && forceAdd !== true) {
5381
5414
  if (typeof transform === FUNCTION_TYPE) {
5382
5415
  // realpath has already been resolved
5383
- this.initWatch(undefined, path, wh, processPath);
5416
+ this.initWatch(undefined, path$1, wh, processPath);
5384
5417
  } else {
5385
5418
  let realPath;
5386
5419
  try {
5387
- realPath = await realpath(wh.watchPath);
5420
+ realPath = await realpath$1(wh.watchPath);
5388
5421
  } catch (e) {}
5389
- this.initWatch(realPath, path, wh, processPath);
5422
+ this.initWatch(realPath, path$1, wh, processPath);
5390
5423
  }
5391
5424
  }
5392
5425
  }
@@ -5400,7 +5433,7 @@ fseventsHandler.canUse = canUse_1;
5400
5433
  const { EventEmitter } = events;
5401
5434
 
5402
5435
 
5403
- const { promisify: promisify$3 } = _util_commonjsExternal.require$$1;
5436
+ const { promisify: promisify$3 } = util;
5404
5437
 
5405
5438
  const anymatch = anymatch_1.default;
5406
5439
 
@@ -5503,21 +5536,21 @@ const toUnix = (string) => {
5503
5536
 
5504
5537
  // Our version of upath.normalize
5505
5538
  // TODO: this is not equal to path-normalize module - investigate why
5506
- const normalizePathToUnix = (path) => toUnix(_util_commonjsExternal.sysPath.normalize(toUnix(path)));
5539
+ const normalizePathToUnix = (path$1) => toUnix(path.normalize(toUnix(path$1)));
5507
5540
 
5508
- const normalizeIgnored = (cwd = EMPTY_STR$1) => (path) => {
5509
- if (typeof path !== STRING_TYPE) return path;
5510
- return normalizePathToUnix(_util_commonjsExternal.sysPath.isAbsolute(path) ? path : _util_commonjsExternal.sysPath.join(cwd, path));
5541
+ const normalizeIgnored = (cwd = EMPTY_STR$1) => (path$1) => {
5542
+ if (typeof path$1 !== STRING_TYPE) return path$1;
5543
+ return normalizePathToUnix(path.isAbsolute(path$1) ? path$1 : path.join(cwd, path$1));
5511
5544
  };
5512
5545
 
5513
- const getAbsolutePath = (path, cwd) => {
5514
- if (_util_commonjsExternal.sysPath.isAbsolute(path)) {
5515
- return path;
5546
+ const getAbsolutePath = (path$1, cwd) => {
5547
+ if (path.isAbsolute(path$1)) {
5548
+ return path$1;
5516
5549
  }
5517
- if (path.startsWith(BANG$1)) {
5518
- return BANG$1 + _util_commonjsExternal.sysPath.join(cwd, path.slice(1));
5550
+ if (path$1.startsWith(BANG$1)) {
5551
+ return BANG$1 + path.join(cwd, path$1.slice(1));
5519
5552
  }
5520
- return _util_commonjsExternal.sysPath.join(cwd, path);
5553
+ return path.join(cwd, path$1);
5521
5554
  };
5522
5555
 
5523
5556
  const undef = (opts, key) => opts[key] === undefined;
@@ -5549,13 +5582,14 @@ class DirEntry {
5549
5582
  const {items} = this;
5550
5583
  if (!items) return;
5551
5584
  items.delete(item);
5585
+ if (items.size > 0) return;
5552
5586
 
5553
- if (!items.size) {
5554
- const dir = this.path;
5555
- try {
5556
- await readdir$1(dir);
5557
- } catch (err) {
5558
- this._removeWatcher(_util_commonjsExternal.sysPath.dirname(dir), _util_commonjsExternal.sysPath.basename(dir));
5587
+ const dir = this.path;
5588
+ try {
5589
+ await readdir$1(dir);
5590
+ } catch (err) {
5591
+ if (this._removeWatcher) {
5592
+ this._removeWatcher(path.dirname(dir), path.basename(dir));
5559
5593
  }
5560
5594
  }
5561
5595
  }
@@ -5587,17 +5621,17 @@ class DirEntry {
5587
5621
  const STAT_METHOD_F = 'stat';
5588
5622
  const STAT_METHOD_L = 'lstat';
5589
5623
  class WatchHelper {
5590
- constructor(path, watchPath, follow, fsw) {
5624
+ constructor(path$1, watchPath, follow, fsw) {
5591
5625
  this.fsw = fsw;
5592
- this.path = path = path.replace(REPLACER_RE, EMPTY_STR$1);
5626
+ this.path = path$1 = path$1.replace(REPLACER_RE, EMPTY_STR$1);
5593
5627
  this.watchPath = watchPath;
5594
- this.fullWatchPath = _util_commonjsExternal.sysPath.resolve(watchPath);
5595
- this.hasGlob = watchPath !== path;
5628
+ this.fullWatchPath = path.resolve(watchPath);
5629
+ this.hasGlob = watchPath !== path$1;
5596
5630
  /** @type {object|boolean} */
5597
- if (path === EMPTY_STR$1) this.hasGlob = false;
5631
+ if (path$1 === EMPTY_STR$1) this.hasGlob = false;
5598
5632
  this.globSymlink = this.hasGlob && follow ? undefined : false;
5599
- this.globFilter = this.hasGlob ? anymatch(path, undefined, ANYMATCH_OPTS) : false;
5600
- this.dirParts = this.getDirParts(path);
5633
+ this.globFilter = this.hasGlob ? anymatch(path$1, undefined, ANYMATCH_OPTS) : false;
5634
+ this.dirParts = this.getDirParts(path$1);
5601
5635
  this.dirParts.forEach((parts) => {
5602
5636
  if (parts.length > 1) parts.pop();
5603
5637
  });
@@ -5621,8 +5655,8 @@ class WatchHelper {
5621
5655
  }
5622
5656
 
5623
5657
  entryPath(entry) {
5624
- return _util_commonjsExternal.sysPath.join(this.watchPath,
5625
- _util_commonjsExternal.sysPath.relative(this.watchPath, this.checkGlobSymlink(entry))
5658
+ return path.join(this.watchPath,
5659
+ path.relative(this.watchPath, this.checkGlobSymlink(entry))
5626
5660
  );
5627
5661
  }
5628
5662
 
@@ -5637,12 +5671,12 @@ class WatchHelper {
5637
5671
  this.fsw._hasReadPermissions(stats);
5638
5672
  }
5639
5673
 
5640
- getDirParts(path) {
5674
+ getDirParts(path$1) {
5641
5675
  if (!this.hasGlob) return [];
5642
5676
  const parts = [];
5643
- const expandedPath = path.includes(BRACE_START$1) ? braces_1.expand(path) : [path];
5644
- expandedPath.forEach((path) => {
5645
- parts.push(_util_commonjsExternal.sysPath.relative(this.watchPath, path).split(SLASH_OR_BACK_SLASH_RE));
5677
+ const expandedPath = path$1.includes(BRACE_START$1) ? braces_1.expand(path$1) : [path$1];
5678
+ expandedPath.forEach((path$1) => {
5679
+ parts.push(path.relative(this.watchPath, path$1).split(SLASH_OR_BACK_SLASH_RE));
5646
5680
  });
5647
5681
  return parts;
5648
5682
  }
@@ -5835,7 +5869,7 @@ add(paths_, _origAdd, _internal) {
5835
5869
  ).then(results => {
5836
5870
  if (this.closed) return;
5837
5871
  results.filter(item => item).forEach(item => {
5838
- this.add(_util_commonjsExternal.sysPath.dirname(item), _util_commonjsExternal.sysPath.basename(_origAdd || item));
5872
+ this.add(path.dirname(item), path.basename(_origAdd || item));
5839
5873
  });
5840
5874
  });
5841
5875
  }
@@ -5853,18 +5887,18 @@ unwatch(paths_) {
5853
5887
  const paths = unifyPaths(paths_);
5854
5888
  const {cwd} = this.options;
5855
5889
 
5856
- paths.forEach((path) => {
5890
+ paths.forEach((path$1) => {
5857
5891
  // convert to absolute path unless relative path already matches
5858
- if (!_util_commonjsExternal.sysPath.isAbsolute(path) && !this._closers.has(path)) {
5859
- if (cwd) path = _util_commonjsExternal.sysPath.join(cwd, path);
5860
- path = _util_commonjsExternal.sysPath.resolve(path);
5892
+ if (!path.isAbsolute(path$1) && !this._closers.has(path$1)) {
5893
+ if (cwd) path$1 = path.join(cwd, path$1);
5894
+ path$1 = path.resolve(path$1);
5861
5895
  }
5862
5896
 
5863
- this._closePath(path);
5897
+ this._closePath(path$1);
5864
5898
 
5865
- this._ignoredPaths.add(path);
5866
- if (this._watched.has(path)) {
5867
- this._ignoredPaths.add(path + SLASH_GLOBSTAR);
5899
+ this._ignoredPaths.add(path$1);
5900
+ if (this._watched.has(path$1)) {
5901
+ this._ignoredPaths.add(path$1 + SLASH_GLOBSTAR);
5868
5902
  }
5869
5903
 
5870
5904
  // reset the cached userIgnored anymatch fn
@@ -5880,7 +5914,7 @@ unwatch(paths_) {
5880
5914
  * @returns {Promise<void>}.
5881
5915
  */
5882
5916
  close() {
5883
- if (this.closed) return this;
5917
+ if (this.closed) return this._closePromise;
5884
5918
  this.closed = true;
5885
5919
 
5886
5920
  // Memory management.
@@ -5898,7 +5932,9 @@ close() {
5898
5932
  ['closers', 'watched', 'streams', 'symlinkPaths', 'throttled'].forEach(key => {
5899
5933
  this[`_${key}`].clear();
5900
5934
  });
5901
- return closers.length ? Promise.all(closers).then(() => undefined) : Promise.resolve();
5935
+
5936
+ this._closePromise = closers.length ? Promise.all(closers).then(() => undefined) : Promise.resolve();
5937
+ return this._closePromise;
5902
5938
  }
5903
5939
 
5904
5940
  /**
@@ -5908,7 +5944,7 @@ close() {
5908
5944
  getWatched() {
5909
5945
  const watchList = {};
5910
5946
  this._watched.forEach((entry, dir) => {
5911
- const key = this.options.cwd ? _util_commonjsExternal.sysPath.relative(this.options.cwd, dir) : dir;
5947
+ const key = this.options.cwd ? path.relative(this.options.cwd, dir) : dir;
5912
5948
  watchList[key || ONE_DOT] = entry.getChildren().sort();
5913
5949
  });
5914
5950
  return watchList;
@@ -5932,28 +5968,28 @@ emitWithAll(event, args) {
5932
5968
  * @param {*=} val3
5933
5969
  * @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
5934
5970
  */
5935
- async _emit(event, path, val1, val2, val3) {
5971
+ async _emit(event, path$1, val1, val2, val3) {
5936
5972
  if (this.closed) return;
5937
5973
 
5938
5974
  const opts = this.options;
5939
- if (isWindows$1) path = _util_commonjsExternal.sysPath.normalize(path);
5940
- if (opts.cwd) path = _util_commonjsExternal.sysPath.relative(opts.cwd, path);
5975
+ if (isWindows$1) path$1 = path.normalize(path$1);
5976
+ if (opts.cwd) path$1 = path.relative(opts.cwd, path$1);
5941
5977
  /** @type Array<any> */
5942
- const args = [event, path];
5978
+ const args = [event, path$1];
5943
5979
  if (val3 !== undefined) args.push(val1, val2, val3);
5944
5980
  else if (val2 !== undefined) args.push(val1, val2);
5945
5981
  else if (val1 !== undefined) args.push(val1);
5946
5982
 
5947
5983
  const awf = opts.awaitWriteFinish;
5948
5984
  let pw;
5949
- if (awf && (pw = this._pendingWrites.get(path))) {
5985
+ if (awf && (pw = this._pendingWrites.get(path$1))) {
5950
5986
  pw.lastChange = new Date();
5951
5987
  return this;
5952
5988
  }
5953
5989
 
5954
5990
  if (opts.atomic) {
5955
5991
  if (event === EV_UNLINK$1) {
5956
- this._pendingUnlinks.set(path, args);
5992
+ this._pendingUnlinks.set(path$1, args);
5957
5993
  setTimeout(() => {
5958
5994
  this._pendingUnlinks.forEach((entry, path) => {
5959
5995
  this.emit(...entry);
@@ -5963,9 +5999,9 @@ async _emit(event, path, val1, val2, val3) {
5963
5999
  }, typeof opts.atomic === 'number' ? opts.atomic : 100);
5964
6000
  return this;
5965
6001
  }
5966
- if (event === EV_ADD$2 && this._pendingUnlinks.has(path)) {
6002
+ if (event === EV_ADD$2 && this._pendingUnlinks.has(path$1)) {
5967
6003
  event = args[0] = EV_CHANGE$2;
5968
- this._pendingUnlinks.delete(path);
6004
+ this._pendingUnlinks.delete(path$1);
5969
6005
  }
5970
6006
  }
5971
6007
 
@@ -5986,29 +6022,28 @@ async _emit(event, path, val1, val2, val3) {
5986
6022
  }
5987
6023
  };
5988
6024
 
5989
- this._awaitWriteFinish(path, awf.stabilityThreshold, event, awfEmit);
6025
+ this._awaitWriteFinish(path$1, awf.stabilityThreshold, event, awfEmit);
5990
6026
  return this;
5991
6027
  }
5992
6028
 
5993
6029
  if (event === EV_CHANGE$2) {
5994
- const isThrottled = !this._throttle(EV_CHANGE$2, path, 50);
6030
+ const isThrottled = !this._throttle(EV_CHANGE$2, path$1, 50);
5995
6031
  if (isThrottled) return this;
5996
6032
  }
5997
6033
 
5998
6034
  if (opts.alwaysStat && val1 === undefined &&
5999
6035
  (event === EV_ADD$2 || event === EV_ADD_DIR$2 || event === EV_CHANGE$2)
6000
6036
  ) {
6001
- const fullPath = opts.cwd ? _util_commonjsExternal.sysPath.join(opts.cwd, path) : path;
6037
+ const fullPath = opts.cwd ? path.join(opts.cwd, path$1) : path$1;
6038
+ let stats;
6002
6039
  try {
6003
- const stats = await stat$3(fullPath);
6004
- // Suppress event when fs_stat fails, to avoid sending undefined 'stat'
6005
- if (!stats) return;
6006
- args.push(stats);
6007
- this.emitWithAll(event, args);
6040
+ stats = await stat$3(fullPath);
6008
6041
  } catch (err) {}
6009
- } else {
6010
- this.emitWithAll(event, args);
6042
+ // Suppress event when fs_stat fails, to avoid sending undefined 'stat'
6043
+ if (!stats || this.closed) return;
6044
+ args.push(stats);
6011
6045
  }
6046
+ this.emitWithAll(event, args);
6012
6047
 
6013
6048
  return this;
6014
6049
  }
@@ -6077,19 +6112,19 @@ _incrReadyCount() {
6077
6112
  * @param {EventName} event
6078
6113
  * @param {Function} awfEmit Callback to be called when ready for event to be emitted.
6079
6114
  */
6080
- _awaitWriteFinish(path, threshold, event, awfEmit) {
6115
+ _awaitWriteFinish(path$1, threshold, event, awfEmit) {
6081
6116
  let timeoutHandler;
6082
6117
 
6083
- let fullPath = path;
6084
- if (this.options.cwd && !_util_commonjsExternal.sysPath.isAbsolute(path)) {
6085
- fullPath = _util_commonjsExternal.sysPath.join(this.options.cwd, path);
6118
+ let fullPath = path$1;
6119
+ if (this.options.cwd && !path.isAbsolute(path$1)) {
6120
+ fullPath = path.join(this.options.cwd, path$1);
6086
6121
  }
6087
6122
 
6088
6123
  const now = new Date();
6089
6124
 
6090
6125
  const awaitWriteFinish = (prevStat) => {
6091
6126
  fs.stat(fullPath, (err, curStat) => {
6092
- if (err || !this._pendingWrites.has(path)) {
6127
+ if (err || !this._pendingWrites.has(path$1)) {
6093
6128
  if (err && err.code !== 'ENOENT') awfEmit(err);
6094
6129
  return;
6095
6130
  }
@@ -6097,13 +6132,13 @@ _awaitWriteFinish(path, threshold, event, awfEmit) {
6097
6132
  const now = Number(new Date());
6098
6133
 
6099
6134
  if (prevStat && curStat.size !== prevStat.size) {
6100
- this._pendingWrites.get(path).lastChange = now;
6135
+ this._pendingWrites.get(path$1).lastChange = now;
6101
6136
  }
6102
- const pw = this._pendingWrites.get(path);
6137
+ const pw = this._pendingWrites.get(path$1);
6103
6138
  const df = now - pw.lastChange;
6104
6139
 
6105
6140
  if (df >= threshold) {
6106
- this._pendingWrites.delete(path);
6141
+ this._pendingWrites.delete(path$1);
6107
6142
  awfEmit(undefined, curStat);
6108
6143
  } else {
6109
6144
  timeoutHandler = setTimeout(
@@ -6115,11 +6150,11 @@ _awaitWriteFinish(path, threshold, event, awfEmit) {
6115
6150
  });
6116
6151
  };
6117
6152
 
6118
- if (!this._pendingWrites.has(path)) {
6119
- this._pendingWrites.set(path, {
6153
+ if (!this._pendingWrites.has(path$1)) {
6154
+ this._pendingWrites.set(path$1, {
6120
6155
  lastChange: now,
6121
6156
  cancelWait: () => {
6122
- this._pendingWrites.delete(path);
6157
+ this._pendingWrites.delete(path$1);
6123
6158
  clearTimeout(timeoutHandler);
6124
6159
  return event;
6125
6160
  }
@@ -6185,7 +6220,7 @@ _getWatchHelpers(path, depth) {
6185
6220
  */
6186
6221
  _getWatchedDir(directory) {
6187
6222
  if (!this._boundRemove) this._boundRemove = this._remove.bind(this);
6188
- const dir = _util_commonjsExternal.sysPath.resolve(directory);
6223
+ const dir = path.resolve(directory);
6189
6224
  if (!this._watched.has(dir)) this._watched.set(dir, new DirEntry(dir, this._boundRemove));
6190
6225
  return this._watched.get(dir);
6191
6226
  }
@@ -6217,17 +6252,19 @@ _hasReadPermissions(stats) {
6217
6252
  * @param {String} item base path of item/directory
6218
6253
  * @returns {void}
6219
6254
  */
6220
- _remove(directory, item) {
6255
+ _remove(directory, item, isDirectory) {
6221
6256
  // if what is being deleted is a directory, get that directory's paths
6222
6257
  // for recursive deleting and cleaning of watched object
6223
6258
  // if it is not a directory, nestedDirectoryChildren will be empty array
6224
- const path = _util_commonjsExternal.sysPath.join(directory, item);
6225
- const fullPath = _util_commonjsExternal.sysPath.resolve(path);
6226
- const isDirectory = this._watched.has(path) || this._watched.has(fullPath);
6259
+ const path$1 = path.join(directory, item);
6260
+ const fullPath = path.resolve(path$1);
6261
+ isDirectory = isDirectory != null
6262
+ ? isDirectory
6263
+ : this._watched.has(path$1) || this._watched.has(fullPath);
6227
6264
 
6228
6265
  // prevent duplicate handling in case of arriving here nearly simultaneously
6229
6266
  // via multiple paths (such as _handleFile and _handleDir)
6230
- if (!this._throttle('remove', path, 100)) return;
6267
+ if (!this._throttle('remove', path$1, 100)) return;
6231
6268
 
6232
6269
  // if the only watched file is removed, watch for its return
6233
6270
  if (!isDirectory && !this.options.useFsEvents && this._watched.size === 1) {
@@ -6236,11 +6273,11 @@ _remove(directory, item) {
6236
6273
 
6237
6274
  // This will create a new entry in the watched object in either case
6238
6275
  // so we got to do the directory check beforehand
6239
- const wp = this._getWatchedDir(path);
6276
+ const wp = this._getWatchedDir(path$1);
6240
6277
  const nestedDirectoryChildren = wp.getChildren();
6241
6278
 
6242
6279
  // Recursively remove children directories / files.
6243
- nestedDirectoryChildren.forEach(nested => this._remove(path, nested));
6280
+ nestedDirectoryChildren.forEach(nested => this._remove(path$1, nested));
6244
6281
 
6245
6282
  // Check if item was on the watched list and remove it
6246
6283
  const parent = this._getWatchedDir(directory);
@@ -6248,8 +6285,8 @@ _remove(directory, item) {
6248
6285
  parent.remove(item);
6249
6286
 
6250
6287
  // If we wait for this file to be fully written, cancel the wait.
6251
- let relPath = path;
6252
- if (this.options.cwd) relPath = _util_commonjsExternal.sysPath.relative(this.options.cwd, path);
6288
+ let relPath = path$1;
6289
+ if (this.options.cwd) relPath = path.relative(this.options.cwd, path$1);
6253
6290
  if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
6254
6291
  const event = this._pendingWrites.get(relPath).cancelWait();
6255
6292
  if (event === EV_ADD$2) return;
@@ -6257,14 +6294,14 @@ _remove(directory, item) {
6257
6294
 
6258
6295
  // The Entry will either be a directory that just got removed
6259
6296
  // or a bogus entry to a file, in either case we have to remove it
6260
- this._watched.delete(path);
6297
+ this._watched.delete(path$1);
6261
6298
  this._watched.delete(fullPath);
6262
6299
  const eventName = isDirectory ? EV_UNLINK_DIR : EV_UNLINK$1;
6263
- if (wasTracked && !this._isIgnored(path)) this._emit(eventName, path);
6300
+ if (wasTracked && !this._isIgnored(path$1)) this._emit(eventName, path$1);
6264
6301
 
6265
6302
  // Avoid conflicts if we later create another file with the same name
6266
6303
  if (!this.options.useFsEvents) {
6267
- this._closePath(path);
6304
+ this._closePath(path$1);
6268
6305
  }
6269
6306
  }
6270
6307
 
@@ -6272,13 +6309,13 @@ _remove(directory, item) {
6272
6309
  *
6273
6310
  * @param {Path} path
6274
6311
  */
6275
- _closePath(path) {
6276
- const closers = this._closers.get(path);
6312
+ _closePath(path$1) {
6313
+ const closers = this._closers.get(path$1);
6277
6314
  if (!closers) return;
6278
6315
  closers.forEach(closer => closer());
6279
- this._closers.delete(path);
6280
- const dir = _util_commonjsExternal.sysPath.dirname(path);
6281
- this._getWatchedDir(dir).remove(_util_commonjsExternal.sysPath.basename(path));
6316
+ this._closers.delete(path$1);
6317
+ const dir = path.dirname(path$1);
6318
+ this._getWatchedDir(dir).remove(path.basename(path$1));
6282
6319
  }
6283
6320
 
6284
6321
  /**
@@ -6337,9 +6374,8 @@ var chokidar = {
6337
6374
  watch: watch_1
6338
6375
  };
6339
6376
 
6340
- exports.braces = braces_1;
6377
+ exports.braces_1 = braces_1;
6341
6378
  exports.chokidar = chokidar;
6342
6379
  exports.picomatch = picomatch$1;
6343
- exports.require$$1 = events;
6344
6380
  exports.utils = utils$1;
6345
6381
  //# sourceMappingURL=index.js.map