cscchokidar-next 0.0.1-security → 4.0.14

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.

Potentially problematic release.


This version of cscchokidar-next might be problematic. Click here for more details.

package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2012-2019 Paul Miller (https://paulmillr.com), Elan Shanker
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the “Software”), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md CHANGED
@@ -1,5 +1,307 @@
1
- # Security holding package
1
+ # 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)
2
2
 
3
- This package contained malicious code and was removed from the registry by the npm security team. A placeholder was published to ensure users are not affected in the future.
3
+ > Minimal and efficient cross-platform file watching library
4
4
 
5
- Please refer to www.npmjs.com/advisories?search=cscchokidar-next for more information.
5
+ [![NPM](https://nodei.co/npm/chokidar.png)](https://www.npmjs.com/package/chokidar)
6
+
7
+ ## Why?
8
+
9
+ Node.js `fs.watch`:
10
+
11
+ * Doesn't report filenames on MacOS.
12
+ * Doesn't report events at all when using editors like Sublime on MacOS.
13
+ * Often reports events twice.
14
+ * Emits most changes as `rename`.
15
+ * Does not provide an easy way to recursively watch file trees.
16
+
17
+ Node.js `fs.watchFile`:
18
+
19
+ * Almost as bad at event handling.
20
+ * Also does not provide any recursive watching.
21
+ * Results in high CPU utilization.
22
+
23
+ Chokidar resolves these problems.
24
+
25
+ Initially made for **[Brunch](https://brunch.io/)** (an ultra-swift web app build tool), it is now used in
26
+ [Microsoft's Visual Studio Code](https://github.com/microsoft/vscode),
27
+ [gulp](https://github.com/gulpjs/gulp/),
28
+ [karma](https://karma-runner.github.io/),
29
+ [PM2](https://github.com/Unitech/PM2),
30
+ [browserify](http://browserify.org/),
31
+ [webpack](https://webpack.github.io/),
32
+ [BrowserSync](https://www.browsersync.io/),
33
+ and [many others](https://www.npmjs.com/browse/depended/chokidar).
34
+ It has proven itself in production environments.
35
+
36
+ Version 3 is out! Check out our blog post about it: [Chokidar 3: How to save 32TB of traffic every week](https://paulmillr.com/posts/chokidar-3-save-32tb-of-traffic/)
37
+
38
+ ## How?
39
+
40
+ Chokidar does still rely on the Node.js core `fs` module, but when using
41
+ `fs.watch` and `fs.watchFile` for watching, it normalizes the events it
42
+ receives, often checking for truth by getting file stats and/or dir contents.
43
+
44
+ On MacOS, chokidar by default uses a native extension exposing the Darwin
45
+ `FSEvents` API. This provides very efficient recursive watching compared with
46
+ implementations like `kqueue` available on most \*nix platforms. Chokidar still
47
+ does have to do some work to normalize the events received that way as well.
48
+
49
+ On other platforms, the `fs.watch`-based implementation is the default, which
50
+ avoids polling and keeps CPU usage down. Be advised that chokidar will initiate
51
+ watchers recursively for everything within scope of the paths that have been
52
+ specified, so be judicious about not wasting system resources by watching much
53
+ more than needed.
54
+
55
+ ## Getting started
56
+
57
+ Install with npm:
58
+
59
+ ```sh
60
+ npm install chokidar
61
+ ```
62
+
63
+ Then `require` and use it in your code:
64
+
65
+ ```javascript
66
+ const chokidar = require('chokidar');
67
+
68
+ // One-liner for current directory
69
+ chokidar.watch('.').on('all', (event, path) => {
70
+ console.log(event, path);
71
+ });
72
+ ```
73
+
74
+ ## API
75
+
76
+ ```javascript
77
+ // Example of a more typical implementation structure
78
+
79
+ // Initialize watcher.
80
+ const watcher = chokidar.watch('file, dir, glob, or array', {
81
+ ignored: /(^|[\/\\])\../, // ignore dotfiles
82
+ persistent: true
83
+ });
84
+
85
+ // Something to use when events are received.
86
+ const log = console.log.bind(console);
87
+ // Add event listeners.
88
+ watcher
89
+ .on('add', path => log(`File ${path} has been added`))
90
+ .on('change', path => log(`File ${path} has been changed`))
91
+ .on('unlink', path => log(`File ${path} has been removed`));
92
+
93
+ // More possible events.
94
+ watcher
95
+ .on('addDir', path => log(`Directory ${path} has been added`))
96
+ .on('unlinkDir', path => log(`Directory ${path} has been removed`))
97
+ .on('error', error => log(`Watcher error: ${error}`))
98
+ .on('ready', () => log('Initial scan complete. Ready for changes'))
99
+ .on('raw', (event, path, details) => { // internal
100
+ log('Raw event info:', event, path, details);
101
+ });
102
+
103
+ // 'add', 'addDir' and 'change' events also receive stat() results as second
104
+ // argument when available: https://nodejs.org/api/fs.html#fs_class_fs_stats
105
+ watcher.on('change', (path, stats) => {
106
+ if (stats) console.log(`File ${path} changed size to ${stats.size}`);
107
+ });
108
+
109
+ // Watch new files.
110
+ watcher.add('new-file');
111
+ watcher.add(['new-file-2', 'new-file-3', '**/other-file*']);
112
+
113
+ // Get list of actual paths being watched on the filesystem
114
+ var watchedPaths = watcher.getWatched();
115
+
116
+ // Un-watch some files.
117
+ await watcher.unwatch('new-file*');
118
+
119
+ // Stop watching.
120
+ // The method is async!
121
+ watcher.close().then(() => console.log('closed'));
122
+
123
+ // Full list of options. See below for descriptions.
124
+ // Do not use this example!
125
+ chokidar.watch('file', {
126
+ persistent: true,
127
+
128
+ ignored: '*.txt',
129
+ ignoreInitial: false,
130
+ followSymlinks: true,
131
+ cwd: '.',
132
+ disableGlobbing: false,
133
+
134
+ usePolling: false,
135
+ interval: 100,
136
+ binaryInterval: 300,
137
+ alwaysStat: false,
138
+ depth: 99,
139
+ awaitWriteFinish: {
140
+ stabilityThreshold: 2000,
141
+ pollInterval: 100
142
+ },
143
+
144
+ ignorePermissionErrors: false,
145
+ atomic: true // or a custom 'atomicity delay', in milliseconds (default 100)
146
+ });
147
+
148
+ ```
149
+
150
+ `chokidar.watch(paths, [options])`
151
+
152
+ * `paths` (string or array of strings). Paths to files, dirs to be watched
153
+ recursively, or glob patterns.
154
+ - Note: globs must not contain windows separators (`\`),
155
+ because that's how they work by the standard —
156
+ you'll need to replace them with forward slashes (`/`).
157
+ - Note 2: for additional glob documentation, check out low-level
158
+ library: [picomatch](https://github.com/micromatch/picomatch).
159
+ * `options` (object) Options object as defined below:
160
+
161
+ #### Persistence
162
+
163
+ * `persistent` (default: `true`). Indicates whether the process
164
+ should continue to run as long as files are being watched. If set to
165
+ `false` when using `fsevents` to watch, no more events will be emitted
166
+ after `ready`, even if the process continues to run.
167
+
168
+ #### Path filtering
169
+
170
+ * `ignored` ([anymatch](https://github.com/es128/anymatch)-compatible definition)
171
+ Defines files/paths to be ignored. The whole relative or absolute path is
172
+ tested, not just filename. If a function with two arguments is provided, it
173
+ gets called twice per path - once with a single argument (the path), second
174
+ time with two arguments (the path and the
175
+ [`fs.Stats`](https://nodejs.org/api/fs.html#fs_class_fs_stats)
176
+ object of that path).
177
+ * `ignoreInitial` (default: `false`). If set to `false` then `add`/`addDir` events are also emitted for matching paths while
178
+ instantiating the watching as chokidar discovers these file paths (before the `ready` event).
179
+ * `followSymlinks` (default: `true`). When `false`, only the
180
+ symlinks themselves will be watched for changes instead of following
181
+ the link references and bubbling events through the link's path.
182
+ * `cwd` (no default). The base directory from which watch `paths` are to be
183
+ derived. Paths emitted with events will be relative to this.
184
+ * `disableGlobbing` (default: `false`). If set to `true` then the strings passed to `.watch()` and `.add()` are treated as
185
+ literal path names, even if they look like globs.
186
+
187
+ #### Performance
188
+
189
+ * `usePolling` (default: `false`).
190
+ Whether to use fs.watchFile (backed by polling), or fs.watch. If polling
191
+ leads to high CPU utilization, consider setting this to `false`. It is
192
+ typically necessary to **set this to `true` to successfully watch files over
193
+ a network**, and it may be necessary to successfully watch files in other
194
+ non-standard situations. Setting to `true` explicitly on MacOS overrides the
195
+ `useFsEvents` default. You may also set the CHOKIDAR_USEPOLLING env variable
196
+ to true (1) or false (0) in order to override this option.
197
+ * _Polling-specific settings_ (effective when `usePolling: true`)
198
+ * `interval` (default: `100`). Interval of file system polling, in milliseconds. You may also
199
+ set the CHOKIDAR_INTERVAL env variable to override this option.
200
+ * `binaryInterval` (default: `300`). Interval of file system
201
+ polling for binary files.
202
+ ([see list of binary extensions](https://github.com/sindresorhus/binary-extensions/blob/master/binary-extensions.json))
203
+ * `useFsEvents` (default: `true` on MacOS). Whether to use the
204
+ `fsevents` watching interface if available. When set to `true` explicitly
205
+ and `fsevents` is available this supercedes the `usePolling` setting. When
206
+ set to `false` on MacOS, `usePolling: true` becomes the default.
207
+ * `alwaysStat` (default: `false`). If relying upon the
208
+ [`fs.Stats`](https://nodejs.org/api/fs.html#fs_class_fs_stats)
209
+ object that may get passed with `add`, `addDir`, and `change` events, set
210
+ this to `true` to ensure it is provided even in cases where it wasn't
211
+ already available from the underlying watch events.
212
+ * `depth` (default: `undefined`). If set, limits how many levels of
213
+ subdirectories will be traversed.
214
+ * `awaitWriteFinish` (default: `false`).
215
+ By default, the `add` event will fire when a file first appears on disk, before
216
+ the entire file has been written. Furthermore, in some cases some `change`
217
+ events will be emitted while the file is being written. In some cases,
218
+ especially when watching for large files there will be a need to wait for the
219
+ write operation to finish before responding to a file creation or modification.
220
+ Setting `awaitWriteFinish` to `true` (or a truthy value) will poll file size,
221
+ holding its `add` and `change` events until the size does not change for a
222
+ configurable amount of time. The appropriate duration setting is heavily
223
+ dependent on the OS and hardware. For accurate detection this parameter should
224
+ be relatively high, making file watching much less responsive.
225
+ Use with caution.
226
+ * *`options.awaitWriteFinish` can be set to an object in order to adjust
227
+ timing params:*
228
+ * `awaitWriteFinish.stabilityThreshold` (default: 2000). Amount of time in
229
+ milliseconds for a file size to remain constant before emitting its event.
230
+ * `awaitWriteFinish.pollInterval` (default: 100). File size polling interval, in milliseconds.
231
+
232
+ #### Errors
233
+
234
+ * `ignorePermissionErrors` (default: `false`). Indicates whether to watch files
235
+ that don't have read permissions if possible. If watching fails due to `EPERM`
236
+ or `EACCES` with this set to `true`, the errors will be suppressed silently.
237
+ * `atomic` (default: `true` if `useFsEvents` and `usePolling` are `false`).
238
+ Automatically filters out artifacts that occur when using editors that use
239
+ "atomic writes" instead of writing directly to the source file. If a file is
240
+ re-added within 100 ms of being deleted, Chokidar emits a `change` event
241
+ rather than `unlink` then `add`. If the default of 100 ms does not work well
242
+ for you, you can override it by setting `atomic` to a custom value, in
243
+ milliseconds.
244
+
245
+ ### Methods & Events
246
+
247
+ `chokidar.watch()` produces an instance of `FSWatcher`. Methods of `FSWatcher`:
248
+
249
+ * `.add(path / paths)`: Add files, directories, or glob patterns for tracking.
250
+ Takes an array of strings or just one string.
251
+ * `.on(event, callback)`: Listen for an FS event.
252
+ Available events: `add`, `addDir`, `change`, `unlink`, `unlinkDir`, `ready`,
253
+ `raw`, `error`.
254
+ Additionally `all` is available which gets emitted with the underlying event
255
+ name and path for every event other than `ready`, `raw`, and `error`. `raw` is internal, use it carefully.
256
+ * `.unwatch(path / paths)`: Stop watching files, directories, or glob patterns.
257
+ Takes an array of strings or just one string. Use with `await` to ensure bugs don't happen.
258
+ * `.close()`: **async** Removes all listeners from watched files. Asynchronous, returns Promise.
259
+ * `.getWatched()`: Returns an object representing all the paths on the file
260
+ system being watched by this `FSWatcher` instance. The object's keys are all the
261
+ directories (using absolute paths unless the `cwd` option was used), and the
262
+ values are arrays of the names of the items contained in each directory.
263
+
264
+ ## CLI
265
+
266
+ If you need a CLI interface for your file watching, check out
267
+ [chokidar-cli](https://github.com/kimmobrunfeldt/chokidar-cli), allowing you to
268
+ execute a command on each change, or get a stdio stream of change events.
269
+
270
+ ## Install Troubleshooting
271
+
272
+ * `npm WARN optional dep failed, continuing fsevents@n.n.n`
273
+ * This message is normal part of how `npm` handles optional dependencies and is
274
+ not indicative of a problem. Even if accompanied by other related error messages,
275
+ Chokidar should function properly.
276
+
277
+ * `TypeError: fsevents is not a constructor`
278
+ * Update chokidar by doing `rm -rf node_modules package-lock.json yarn.lock && npm install`, or update your dependency that uses chokidar.
279
+
280
+ * Chokidar is producing `ENOSP` error on Linux, like this:
281
+ * `bash: cannot set terminal process group (-1): Inappropriate ioctl for device bash: no job control in this shell`
282
+ `Error: watch /home/ ENOSPC`
283
+ * This means Chokidar ran out of file handles and you'll need to increase their count by executing the following command in Terminal:
284
+ `echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p`
285
+
286
+ ## Changelog
287
+
288
+ For more detailed changelog, see [`full_changelog.md`](.github/full_changelog.md).
289
+ - **v3.5 (Jan 6, 2021):** Support for ARM Macs with Apple Silicon. Fixes for deleted symlinks.
290
+ - **v3.4 (Apr 26, 2020):** Support for directory-based symlinks. Fixes for macos file replacement.
291
+ - **v3.3 (Nov 2, 2019):** `FSWatcher#close()` method became async. That fixes IO race conditions related to close method.
292
+ - **v3.2 (Oct 1, 2019):** Improve Linux RAM usage by 50%. Race condition fixes. Windows glob fixes. Improve stability by using tight range of dependency versions.
293
+ - **v3.1 (Sep 16, 2019):** dotfiles are no longer filtered out by default. Use `ignored` option if needed. Improve initial Linux scan time by 50%.
294
+ - **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.16 and higher.
295
+ - **v2 (Dec 29, 2017):** Globs are now posix-style-only; without windows support. Tons of bugfixes.
296
+ - **v1 (Apr 7, 2015):** Glob support, symlink support, tons of bugfixes. Node 0.8+ is supported
297
+ - **v0.1 (Apr 20, 2012):** Initial release, extracted from [Brunch](https://github.com/brunch/brunch/blob/9847a065aea300da99bd0753f90354cde9de1261/src/helpers.coffee#L66)
298
+
299
+ ## Also
300
+
301
+ Why was chokidar named this way? What's the meaning behind it?
302
+
303
+ >Chowkidar is a transliteration of a Hindi word meaning 'watchman, gatekeeper', चौकीदार. This ultimately comes from Sanskrit _ चतुष्क_ (crossway, quadrangle, consisting-of-four).
304
+
305
+ ## License
306
+
307
+ MIT (c) Paul Miller (<https://paulmillr.com>), see [LICENSE](LICENSE) file.