Comparing version 3.0.2 to 3.1.0
24
index.js
@@ -6,3 +6,3 @@ 'use strict'; | ||
const readdirp = require('readdirp'); | ||
const anymatch = require('anymatch'); | ||
const anymatch = require('anymatch').default; | ||
const globParent = require('glob-parent'); | ||
@@ -69,2 +69,3 @@ const isGlob = require('is-glob'); | ||
const REPLACER_RE = /^\.[\/\\]/; | ||
const ANYMATCH_OPTS = {dot: true}; | ||
const STRING_TYPE = 'string'; | ||
@@ -157,3 +158,3 @@ const EMPTY_FN = () => {}; | ||
this.globSymlink = this.hasGlob && follow ? null : false; | ||
this.globFilter = this.hasGlob ? anymatch(path) : false; | ||
this.globFilter = this.hasGlob ? anymatch(path, undefined, ANYMATCH_OPTS) : false; | ||
this.dirParts = this.getDirParts(path); | ||
@@ -192,3 +193,4 @@ this.dirParts.forEach((parts) => { | ||
const resolvedPath = this.entryPath(entry); | ||
const matchesGlob = this.hasGlob ? this.globFilter(resolvedPath) : true; | ||
const matchesGlob = this.hasGlob && typeof this.globFilter === 'function' ? | ||
this.globFilter(resolvedPath) : true; | ||
return matchesGlob && | ||
@@ -218,3 +220,3 @@ this.fsw._isntIgnored(resolvedPath, stats) && | ||
if (part === GLOBSTAR) globstar = true; | ||
return globstar || !entryParts[0][i] || anymatch(part, entryParts[0][i]); | ||
return globstar || !entryParts[0][i] || anymatch(part, entryParts[0][i], ANYMATCH_OPTS); | ||
}); | ||
@@ -362,3 +364,3 @@ }); | ||
*/ | ||
async add(paths_, _origAdd, _internal) { | ||
add(paths_, _origAdd, _internal) { | ||
const {cwd, disableGlobbing} = this.options; | ||
@@ -410,3 +412,3 @@ this.closed = false; | ||
this._readyCount += paths.length; | ||
const results = await Promise.all( | ||
Promise.all( | ||
paths.map(async path => { | ||
@@ -417,6 +419,7 @@ const res = await this._nodeFsHandler._addToNodeFs(path, !_internal, 0, 0, _origAdd); | ||
}) | ||
); | ||
results.forEach((item) => { | ||
if (!item || this.closed) return; | ||
this.add(sysPath.dirname(item), sysPath.basename(_origAdd || item)); | ||
).then(results => { | ||
if (this.closed) return; | ||
results.filter(item => item).forEach(item => { | ||
this.add(sysPath.dirname(item), sysPath.basename(_origAdd || item)); | ||
}); | ||
}); | ||
@@ -734,2 +737,3 @@ } | ||
.concat(paths) | ||
, undefined, ANYMATCH_OPTS | ||
); | ||
@@ -736,0 +740,0 @@ } |
@@ -184,6 +184,5 @@ 'use strict'; | ||
/** | ||
* @param {FSWatcher} fsW | ||
* @param {import('../index').FSWatcher} fsW | ||
*/ | ||
constructor(fsW) { | ||
const FSWatcher = require('../index').FSWatcher; | ||
this.fsw = fsW; | ||
@@ -330,3 +329,3 @@ } | ||
* @param {Number} curDepth level of subdirectories traversed to where symlink is | ||
* @returns {void} | ||
* @returns {Promise<void>} | ||
*/ | ||
@@ -405,3 +404,3 @@ async _handleFsEventsSymlink(linkPath, fullPath, transform, curDepth) { | ||
* @param {Number=} priorDepth Level of subdirectories already traversed. | ||
* @returns {void} | ||
* @returns {Promise<void>} | ||
*/ | ||
@@ -408,0 +407,0 @@ async _addToFsEvents(path, transform, forceAdd, priorDepth) { |
@@ -12,3 +12,3 @@ 'use strict'; | ||
const close = promisify(fs.close); | ||
const realpath = promisify(fs.realpath); | ||
const fsrealpath = promisify(fs.realpath); | ||
@@ -248,6 +248,5 @@ const statMethods = { lstat, stat }; | ||
/** | ||
* @param {FSWatcher} fsW | ||
* @param {import("../index").FSWatcher} fsW | ||
*/ | ||
constructor(fsW) { | ||
const FSWatcher = require('../index').FSWatcher; | ||
this.fsw = fsW; | ||
@@ -370,3 +369,3 @@ this._boundHandleError = (error) => fsW._handleError(error); | ||
this.fsw._incrReadyCount(); | ||
const linkPath = await realpath(path); | ||
const linkPath = await fsrealpath(path); | ||
if (dir.has(item)) { | ||
@@ -540,5 +539,6 @@ if (this.fsw._symlinkPaths.get(full) !== linkPath) { | ||
const targetPath = path.includes("*") || path.includes("{") ? path : await realpath(path); | ||
const follow = this.fsw.options.followSymlinks && !path.includes("*") && !path.includes("{"); | ||
let closer; | ||
if (stats.isDirectory()) { | ||
const targetPath = follow ? await fsrealpath(path) : path; | ||
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath); | ||
@@ -550,2 +550,3 @@ // preserve this symlink's target path | ||
} else if (stats.isSymbolicLink()) { | ||
const targetPath = follow ? await fsrealpath(path) : path; | ||
const parent = sysPath.dirname(wh.watchPath); | ||
@@ -552,0 +553,0 @@ this.fsw._getWatchedDir(parent).add(wh.watchPath); |
{ | ||
"name": "chokidar", | ||
"description": "A neat wrapper around node.js fs.watch / fs.watchFile / fsevents.", | ||
"version": "3.0.2", | ||
"version": "3.1.0", | ||
"homepage": "https://github.com/paulmillr/chokidar", | ||
@@ -15,3 +15,3 @@ "author": "Paul Miller (https://paulmillr.com)", | ||
"dependencies": { | ||
"anymatch": "^3.0.1", | ||
"anymatch": "^3.1.0", | ||
"braces": "^3.0.2", | ||
@@ -18,0 +18,0 @@ "glob-parent": "^5.0.0", |
@@ -65,4 +65,4 @@ # Chokidar [![Weekly downloads](https://img.shields.io/npm/dw/chokidar.svg)](https://github.com/paulmillr/chokidar) [![Yearly downloads](https://img.shields.io/npm/dy/chokidar.svg)](https://github.com/paulmillr/chokidar) | ||
// One-liner for current directory, ignores .dotfiles | ||
chokidar.watch('.', {ignored: /(^|[\/\\])\../}).on('all', (event, path) => { | ||
// One-liner for current directory | ||
chokidar.watch('.').on('all', (event, path) => { | ||
console.log(event, path); | ||
@@ -79,3 +79,3 @@ }); | ||
const watcher = chokidar.watch('file, dir, glob, or array', { | ||
ignored: /(^|[\/\\])\../, | ||
ignored: /(^|[\/\\])\../, // ignore dotfiles | ||
persistent: true | ||
@@ -151,2 +151,7 @@ }); | ||
recursively, or glob patterns. | ||
- Note: globs must not contain windows separators (`\`), | ||
because that's how they work by the standard — | ||
you'll need to replace them with forward slashes (`/`). | ||
- Note 2: for additional glob documentation, check out low-level | ||
library: [picomatch](https://github.com/micromatch/picomatch). | ||
* `options` (object) Options object as defined below: | ||
@@ -269,14 +274,16 @@ | ||
* `ERR! stack Error: Python executable "python" is v3.4.1, which is not supported by gyp.` | ||
* You should be able to resolve this by installing python 2.7 and running: | ||
`npm config set python python2.7` | ||
* `TypeError: fsevents is not a constructor` | ||
* Update chokidar by doing `rm -rf node_modules package-lock.json yarn.lock && npm install`, or update your dependency that uses chokidar. | ||
* `gyp ERR! stack Error: not found: make` | ||
* On Mac, install the XCode command-line tools | ||
* Chokidar is producing `ENOSP` error on Linux, like this: | ||
* `bash: cannot set terminal process group (-1): Inappropriate ioctl for device bash: no job control in this shell` | ||
`Error: watch /home/ ENOSPC` | ||
* This means Chokidar ran out of file handles and you'll need to increase their count by executing the following command in Terminal: | ||
`echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p` | ||
## Changelog | ||
For more detailed changelog, see [`.github/full_changelog.md`](.github/full_changelog.md). | ||
For more detailed changelog, see [`full_changelog.md`](.github/full_changelog.md). | ||
- v3.1 (Sep 16, 2019): emit dotfiles by default. You can filter them out by using `ignored` option. Improves Linux performance by 50%. | ||
- v3 (Apr 30, 2019): massive CPU & RAM consumption improvements; reduces deps / package size by a factor of 17x and bumps Node.js requirement to v8 and higher. | ||
@@ -283,0 +290,0 @@ - v2 (Dec 29, 2017): Globs are now posix-style-only; without windows support. Tons of bugfixes. |
@@ -20,3 +20,3 @@ // TypeScript Version: 3.0 | ||
*/ | ||
add(paths: string | string[]): void; | ||
add(paths: string | ReadonlyArray<string>): void; | ||
@@ -27,3 +27,3 @@ /** | ||
*/ | ||
unwatch(paths: string | string[]): void; | ||
unwatch(paths: string | ReadonlyArray<string>): void; | ||
@@ -187,4 +187,4 @@ /** | ||
export function watch( | ||
paths: string | string[], | ||
paths: string | ReadonlyArray<string>, | ||
options?: WatchOptions | ||
): FSWatcher; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
82318
1884
293
1
Updatedanymatch@^3.1.0