Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: paulmillr/chokidar
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 3b1071a6dd82397842f4f7dc63b72c703bd06275
Choose a base ref
...
head repository: paulmillr/chokidar
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7b8e02af255f54bcc3978f2a926cdc0b0ca107b3
Choose a head ref

Commits on May 12, 2017

  1. Copy the full SHA
    3d91781 View commit details

Commits on Jul 22, 2017

  1. Add node v8 to CI configs

    es128 committed Jul 22, 2017
    Copy the full SHA
    528826f View commit details

Commits on Aug 17, 2017

  1. fix for handling braces in path (#622)

    * fix for handling braces in path
    
    * fix entry parts checking
    
    * fix braces test
    
    * fix braces test
    
    * fix paths in test for windows
    MhMadHamster authored and es128 committed Aug 17, 2017
    Copy the full SHA
    cbdf255 View commit details

Commits on Aug 21, 2017

  1. Update globbing deps

    es128 committed Aug 21, 2017
    Copy the full SHA
    cde757a View commit details

Commits on Oct 14, 2017

  1. Fix uncaught exception "Cannot read property 'lastChange' of undefined".

    Includes a test case that reproduces the issue without the fix.
    dsagal committed Oct 14, 2017
    Copy the full SHA
    075f13f View commit details

Commits on Dec 28, 2017

  1. Attempt to fix glob tests

    phated committed Dec 28, 2017
    Copy the full SHA
    a92f089 View commit details
  2. Upgrade other deps

    phated committed Dec 28, 2017
    Copy the full SHA
    2f3112a View commit details

Commits on Dec 29, 2017

  1. Merge pull request #658 from phated/replace-syspath

    Attempt to get tests passing with updated deps
    es128 authored Dec 29, 2017
    Copy the full SHA
    51ca0d5 View commit details
  2. Copy the full SHA
    fe97886 View commit details
  3. Copy the full SHA
    febd028 View commit details
  4. Add node 9 to both CI

    phated committed Dec 29, 2017
    Copy the full SHA
    d2d8132 View commit details
  5. Update AppVeyor badge location

    phated committed Dec 29, 2017
    Copy the full SHA
    4ec944e View commit details
  6. Update changelog for 2.0

    phated committed Dec 29, 2017
    Copy the full SHA
    41021e8 View commit details
  7. Merge pull request #659 from phated/ci-updates

    Update Travis & AppVeyor to allow node 0.10 failures
    es128 authored Dec 29, 2017
    Copy the full SHA
    77cf90f View commit details
  8. Merge pull request #660 from phated/docs

    Update badges/changelog
    es128 authored Dec 29, 2017
    Copy the full SHA
    d5187a2 View commit details
  9. Release 2.0.0

    es128 committed Dec 29, 2017
    2
    Copy the full SHA
    3409db8 View commit details

Commits on Jan 12, 2018

  1. Fix windows ignore when using anymatch@2

    Fixes #668
    
    Chokidar@2 includes anymatch@2 which has a (potentially) breaking change
    as described in the changelog: https://github.com/micromatch/anymatch#change-log
    
    When the `cwd` is set Chokidar will join the ignore pattern to the cwd,
    and if this isn't absolute, it causes `anymatch` to fail:
    
    ```js
    // where cwd = c:\Users\remy\
    anymatch('C:\\Users\\remy\\**\\node_modules\\**',
    'C:\\Users\\remy\\node_modules\\project'); // === false
    ```
    
    https://runkit.com/embed/rn05fobk294p
    
    So this change adds the upath module (used by Chokidar during testing
    and about 35K footprint) to normalize the path to bash-like slashes
    which corrects the issue.
    remy committed Jan 12, 2018
    Copy the full SHA
    966c300 View commit details

Commits on Jan 18, 2018

  1. Merge pull request #669 from remy/master

    Fix windows ignore when using anymatch@2 & cwd option
    es128 authored Jan 18, 2018
    Copy the full SHA
    d26c6e0 View commit details
  2. Merge pull request #644 from dsagal/uncaught_fix

    Fix uncaught exception "Cannot read property 'lastChange' of undefined".
    es128 authored Jan 18, 2018
    Copy the full SHA
    d1bac5b View commit details

Commits on Feb 5, 2018

  1. Update README.md

    Changed to current url
    Lambdac0re authored Feb 5, 2018
    Copy the full SHA
    0b661d0 View commit details

Commits on Feb 8, 2018

  1. Merge pull request #678 from Lambdac0re/patch-1

    Update README.md
    es128 authored Feb 8, 2018
    Copy the full SHA
    5e0710e View commit details
  2. Release 2.0.1

    es128 committed Feb 8, 2018
    Copy the full SHA
    560cbb9 View commit details
  3. Copy the full SHA
    f8c85bf View commit details
  4. Merge pull request #679 from danthegoodman/patch-1

    Accept upath minor and security patches
    es128 authored Feb 8, 2018
    Copy the full SHA
    34432b3 View commit details

Commits on Feb 14, 2018

  1. Release 2.0.2

    es128 committed Feb 14, 2018
    Copy the full SHA
    4813aec View commit details

Commits on Feb 15, 2018

  1. Copy the full SHA
    c821fab View commit details
  2. Merge pull request #682 from caseywebdev/unlink-and-readd

    Unlink and re-add fails when multiple paths are passed
    paulmillr authored Feb 15, 2018
    Copy the full SHA
    a95a1f8 View commit details

Commits on Feb 24, 2018

  1. Add callbacks to fs.close

    This also fixes an issue that using fd = 0 is not closed in case
    Windows is used and a `EPERM` error is triggered.
    BridgeAR committed Feb 24, 2018
    Copy the full SHA
    df88ff0 View commit details

Commits on Feb 26, 2018

  1. Copy the full SHA
    fd37c16 View commit details

Commits on Mar 11, 2018

  1. Merge pull request #687 from BridgeAR/fix-no-callback

    Add callbacks to fs.close
    paulmillr authored Mar 11, 2018
    Copy the full SHA
    dac69b6 View commit details

Commits on Mar 15, 2018

  1. Copy the full SHA
    3fdb7bd View commit details

Commits on Mar 23, 2018

  1. Merge pull request #695 from clmystes/patch-1

    chore: upgrade to `fsevents: ^1.1.2`
    paulmillr authored Mar 23, 2018
    Copy the full SHA
    545e16f View commit details
  2. Release 2.0.3.

    paulmillr committed Mar 23, 2018
    Copy the full SHA
    925b534 View commit details

Commits on Apr 23, 2018

  1. don't use broken fsevents release

    Hi there,
    
    We've had some broken builds today using Chokidar because of a broken `fsevents` release. This PR ensures that we're using at least https://github.com/strongloop/fsevents/releases/tag/v1.2.2
    
    All best,
    Ben
    bjfletcher authored Apr 23, 2018
    Copy the full SHA
    b02f98c View commit details

Commits on Apr 27, 2018

  1. Merge pull request #706 from bjfletcher/patch-1

    don't use broken fsevents release
    es128 authored Apr 27, 2018
    Copy the full SHA
    76aa8e6 View commit details
  2. Add node v10 to CI configs

    es128 committed Apr 27, 2018
    Copy the full SHA
    9d154df View commit details
  3. Merge pull request #690 from bmathews/pr/685

    Add debouncing to readdirp call
    es128 authored Apr 27, 2018
    Copy the full SHA
    5e75390 View commit details

Commits on May 17, 2018

  1. update upath version to avoid errors on node v10

    upath versions lower than 1.0.5 fail to install on node v10
    Gaafar authored May 17, 2018
    Copy the full SHA
    11aea72 View commit details

Commits on May 21, 2018

  1. Merge pull request #717 from Gaafar/patch-1

    update upath version to avoid install errors on node v10
    paulmillr authored May 21, 2018
    Copy the full SHA
    8e5d416 View commit details
  2. Upgrade dependencies

    ehmicky committed May 21, 2018
    Copy the full SHA
    d8970f9 View commit details
  3. Replace istanbul by nyc

    ehmicky committed May 21, 2018
    Copy the full SHA
    be9a1d7 View commit details
  4. Copy the full SHA
    03b6de4 View commit details
  5. Upgrade .gitignore

    ehmicky committed May 21, 2018
    Copy the full SHA
    0122f3b View commit details
  6. Fix coveralls with nyc

    ehmicky committed May 21, 2018
    Copy the full SHA
    a3316f7 View commit details
  7. Merge pull request #719 from ehmicky/master

    Upgrade dependencies
    paulmillr authored May 21, 2018
    Copy the full SHA
    5261384 View commit details

Commits on May 27, 2018

  1. Copy the full SHA
    28a70c4 View commit details
  2. Copy the full SHA
    e2b720c View commit details

Commits on Jun 1, 2018

  1. Copy the full SHA
    bedf196 View commit details
  2. Fix details in tests

    srguiwiz committed Jun 1, 2018
    Copy the full SHA
    a291610 View commit details

Commits on Jun 3, 2018

  1. Copy the full SHA
    260bd29 View commit details
Showing with 3,523 additions and 2,745 deletions.
  1. +38 −0 .github/ISSUE_TEMPLATE/bug_report.md
  2. +44 −0 CHANGELOG.md → .github/full_changelog.md
  3. +2 −1 .gitignore
  4. +0 −8 .jshintrc
  5. +8 −9 .travis.yml
  6. +21 −0 LICENSE
  7. +28 −38 README.md
  8. +0 −27 appveyor.yml
  9. +1 −1 example.js
  10. +613 −453 index.js
  11. +257 −200 lib/fsevents-handler.js
  12. +352 −286 lib/nodefs-handler.js
  13. +65 −39 package.json
  14. +1,833 −1,683 test.js
  15. +187 −0 types/index.d.ts
  16. +60 −0 types/test.ts
  17. +14 −0 types/tsconfig.json
38 changes: 38 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Bug report
about: Create a report to help us improve

---

**Describe the bug**
A clear and concise description of what the bug is.

**Versions (please complete the following information):**
- Chokidar version [e.g. 2.0.4, or commit hash]
- Node version [e.g. 10.4.1]
- OS version: [e.g. Ubuntu 16.04, or Windows 10]

**To Reproduce**
Steps to reproduce the behavior.

Ideally prove a problem by isolating and making it reproducible with a very short sample program, which you could paste here:

```
var chokidar = require('chokidar');
var fs = require('fs');
// One-liner for files and directories starting with 'test'
chokidar.watch('test*', {}).on('all', (event, path) => {
console.log(event, path);
});
fs.writeFileSync('test.txt', 'testing 1');
// In a comment describe expected output versus observed problem
```

Most valuable could be one or more test cases for [test.js](https://github.com/paulmillr/chokidar/blob/master/test.js) to demonstrate the problem.

**Expected behavior**
A clear and concise description of what you expect to happen.

**Additional context**
Add any other context about the problem here.
Optionally nice to know what project you are working on.
44 changes: 44 additions & 0 deletions CHANGELOG.md → .github/full_changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,47 @@
# Chokidar 3.0.0 (Apr 30, 2019)
* Massive CPU & RAM consumption improvements. 17x package & deps size reduction
* Node 8+-only

# Chokidar 2.1.4 (Mar 22, 2019)
* Improve TypeScript type definitions for `on` method.

# Chokidar 2.1.3 (Mar 22, 2019)
* Improve atomic writes handling

# Chokidar 2.1.2 (Feb 18, 2019)
* Add TypeScript type definitions
* More fixes for accessTime behavior (#800)

# Chokidar 2.1.1 (Feb 8, 2019)
* Handle simultaneous change of LastAccessTime and ModifiedTime (#793)

# Chokidar 2.1.0 (Feb 5, 2019)
* Ignore accessTime updates caused by read operations (#762).
* Updated dependencies. Removed `lodash.debounce`.

# Chokidar 2.0.4 (Jun 18, 2018)
* Prevent watcher.close() from crashing (#730).

# Chokidar 2.0.3 (Mar 22, 2018)
* Fixes an issue that using fd = 0 is not closed in case
Windows is used and a `EPERM` error is triggered.

# Chokidar 2.0.2 (Feb 14, 2018)
* Allow semver range updates for upath dependency

# Chokidar 2.0.1 (Feb 8, 2018)
* Fix #668 glob issue on Windows when using `ignore` and `cwd`. Thanks @remy!
* Fix #546 possible uncaught exception when using `awaitWriteFinish`.
Thanks @dsagal!

# Chokidar 2.0.0 (Dec 29, 2017)
* Breaking: Upgrade globbing dependencies which require globs to be more strict and always use POSIX-style slashes because Windows-style slashes are used as escape sequences
* Update tests to work with upgraded globbing dependencies
* Add ability to log FSEvents require error by setting `CHOKIDAR_PRINT_FSEVENTS_REQUIRE_ERROR` env
* Fix for handling braces in globs
* Add node 8 & 9 to CI configs
* Allow node 0.10 failures on Windows

# Chokidar 1.7.0 (May 8, 2017)
* Add `disableGlobbing` option
* Add ability to force interval value by setting CHOKIDAR_INTERVAL env
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_modules
test-fixtures
coverage
*.bak
*.log
.nyc_output
package-lock.json
8 changes: 0 additions & 8 deletions .jshintrc

This file was deleted.

17 changes: 8 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
language: node_js
node_js:
- '7'
- '6'
- '5'
- '4'
- '0.10'
- "12"
- "10"
- "8"
os:
- linux
- osx
script:
- npm run ci-test
sudo: false
- linux
- windows
after_script:
- npm run coveralls
# - npm run dtslint
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2012-2019 Paul Miller (https://paulmillr.com), Elan Shanker

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
66 changes: 28 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
# Chokidar [![Mac/Linux Build Status](https://img.shields.io/travis/paulmillr/chokidar/master.svg?label=Mac%20OSX%20%26%20Linux)](https://travis-ci.org/paulmillr/chokidar) [![Windows Build status](https://img.shields.io/appveyor/ci/es128/chokidar/master.svg?label=Windows)](https://ci.appveyor.com/project/es128/chokidar/branch/master) [![Coverage Status](https://coveralls.io/repos/paulmillr/chokidar/badge.svg)](https://coveralls.io/r/paulmillr/chokidar) [![Join the chat at https://gitter.im/paulmillr/chokidar](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/paulmillr/chokidar?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
# 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)

> A neat wrapper around node.js fs.watch / fs.watchFile / fsevents.
> A neat wrapper around node.js fs.watch / fs.watchFile / FSEvents.
[![NPM](https://nodei.co/npm-dl/chokidar.png)](https://nodei.co/npm/chokidar/)
[![NPM](https://nodei.co/npm/chokidar.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/chokidar/)
[![NPM](https://nodei.co/npm/chokidar.png)](https://www.npmjs.com/package/chokidar)

## Why?
Node.js `fs.watch`:

* Doesn't report filenames on OS X.
* Doesn't report events at all when using editors like Sublime on OS X.
* Doesn't report filenames on MacOS.
* Doesn't report events at all when using editors like Sublime on MacOS.
* Often reports events twice.
* Emits most changes as `rename`.
* Has [a lot of other issues](https://github.com/joyent/node/search?q=fs.watch&type=Issues)
* Does not provide an easy way to recursively watch file trees.

Node.js `fs.watchFile`:
@@ -23,14 +21,14 @@ Node.js `fs.watchFile`:

Chokidar resolves these problems.

Initially made for [brunch](http://brunch.io) (an ultra-swift web app build tool), it is now used in
Initially made for **[Brunch](http://brunch.io)** (an ultra-swift web app build tool), it is now used in
[Microsoft's Visual Studio Code](https://github.com/microsoft/vscode),
[gulp](https://github.com/gulpjs/gulp/),
[karma](http://karma-runner.github.io),
[PM2](https://github.com/Unitech/PM2),
[browserify](http://browserify.org/),
[webpack](http://webpack.github.io/),
[BrowserSync](http://www.browsersync.io/),
[Microsoft's Visual Studio Code](https://github.com/microsoft/vscode),
and [many others](https://www.npmjs.org/browse/depended/chokidar/).
It has proven itself in production environments.

@@ -39,7 +37,7 @@ Chokidar does still rely on the Node.js core `fs` module, but when using
`fs.watch` and `fs.watchFile` for watching, it normalizes the events it
receives, often checking for truth by getting file stats and/or dir contents.

On Mac OS X, chokidar by default uses a native extension exposing the Darwin
On MacOS, chokidar by default uses a native extension exposing the Darwin
`FSEvents` API. This provides very efficient recursive watching compared with
implementations like `kqueue` available on most \*nix platforms. Chokidar still
does have to do some work to normalize the events received that way as well.
@@ -53,30 +51,34 @@ more than needed.
## Getting started
Install with npm:

npm install chokidar --save
```sh
npm install chokidar
```

Then `require` and use it in your code:

```javascript
var chokidar = require('chokidar');
const chokidar = require('chokidar');

// One-liner for current directory, ignores .dotfiles
chokidar.watch('.', {ignored: /(^|[\/\\])\../}).on('all', (event, path) => {
console.log(event, path);
});
```

## API

```javascript
// Example of a more typical implementation structure:

// Initialize watcher.
var watcher = chokidar.watch('file, dir, glob, or array', {
const watcher = chokidar.watch('file, dir, glob, or array', {
ignored: /(^|[\/\\])\../,
persistent: true
});

// Something to use when events are received.
var log = console.log.bind(console);
const log = console.log.bind(console);
// Add event listeners.
watcher
.on('add', path => log(`File ${path} has been added`))
@@ -138,8 +140,6 @@ chokidar.watch('file', {

```

## API

`chokidar.watch(paths, [options])`

* `paths` (string or array of strings). Paths to files, dirs to be watched
@@ -179,19 +179,19 @@ Whether to use fs.watchFile (backed by polling), or fs.watch. If polling
leads to high CPU utilization, consider setting this to `false`. It is
typically necessary to **set this to `true` to successfully watch files over
a network**, and it may be necessary to successfully watch files in other
non-standard situations. Setting to `true` explicitly on OS X overrides the
non-standard situations. Setting to `true` explicitly on MacOS overrides the
`useFsEvents` default. You may also set the CHOKIDAR_USEPOLLING env variable
to true (1) or false (0) in order to override this option.
* _Polling-specific settings_ (effective when `usePolling: true`)
* `interval` (default: `100`). Interval of file system polling. You may also
* `interval` (default: `100`). Interval of file system polling. You may also
set the CHOKIDAR_INTERVAL env variable to override this option.
* `binaryInterval` (default: `300`). Interval of file system
polling for binary files.
([see list of binary extensions](https://github.com/sindresorhus/binary-extensions/blob/master/binary-extensions.json))
* `useFsEvents` (default: `true` on OS X). Whether to use the
* `useFsEvents` (default: `true` on MacOS). Whether to use the
`fsevents` watching interface if available. When set to `true` explicitly
and `fsevents` is available this supercedes the `usePolling` setting. When
set to `false` on OS X, `usePolling: true` becomes the default.
set to `false` on MacOS, `usePolling: true` becomes the default.
* `alwaysStat` (default: `false`). If relying upon the
[`fs.Stats`](http://nodejs.org/api/fs.html#fs_class_fs_stats)
object that may get passed with `add`, `addDir`, and `change` events, set
@@ -268,26 +268,16 @@ execute a command on each change, or get a stdio stream of change events.
* `gyp ERR! stack Error: not found: make`
* On Mac, install the XCode command-line tools

## License

The MIT License (MIT)
## Changelog

Copyright (c) 2016 Paul Miller (http://paulmillr.com) & Elan Shanker
For more detailed changelog, see `.github/full_changelog.md`

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
- v3 (Apr 30, 2019): Massive CPU & RAM consumption improvements. 17x package & deps size reduction. Node 8+-only
- v2 (Dec 29, 2017): Globs are now posix-style-only; without windows support. Tons of bugfixes.
- v1 (Apr 7, 2015): Glob support, symlink support, tons of bugfixes. Node 0.8+ is supported
- v0.1 (Apr 20, 2012): Initial release, extracted from [Brunch](https://github.com/brunch/brunch/blob/9847a065aea300da99bd0753f90354cde9de1261/src/helpers.coffee#L66)

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
## License

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
MIT (c) Paul Miller (https://paulmillr.com), see LICENSE file.
27 changes: 0 additions & 27 deletions appveyor.yml

This file was deleted.

2 changes: 1 addition & 1 deletion example.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require('./').watch('.', {
global.watcher = require('./').watch('.', {
ignored: /node_modules|\.git/,
persistent: true,
// followSymlinks: false,
Loading