Skip to content

Commit

Permalink
chore: upgrade to fsevents 2
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Nov 20, 2019
1 parent be6df92 commit f078d60
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 20 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -76,6 +76,7 @@
- `[jest-cli]` [**BREAKING**] Remove re-exports from `@jest/core` ([#8874](https://github.com/facebook/jest/pull/8874))
- `[jest-diff]` Remove the need to export `splitLines0` function ([#9151](https://github.com/facebook/jest/pull/9151))
- `[jest-environment-jsdom]` [**BREAKING**] Upgrade JSDOM from v11 to v15 ([#8851](https://github.com/facebook/jest/pull/8851))
- `[jest-haste-map]` Upgrade to `fsevents@2` ([#9215](https://github.com/facebook/jest/pull/9215))
- `[jest-util]` [**BREAKING**] Remove deprecated exports ([#8863](https://github.com/facebook/jest/pull/8863))
- `[jest-validate]` [**BREAKING**] Use ESM exports ([#8874](https://github.com/facebook/jest/pull/8874))
- `[jest-types]` Mark `InitialOptions` as `Partial` ([#8848](https://github.com/facebook/jest/pull/8848))
Expand Down
3 changes: 1 addition & 2 deletions packages/jest-haste-map/package.json
Expand Up @@ -25,14 +25,13 @@
"devDependencies": {
"@types/anymatch": "^1.3.1",
"@types/fb-watchman": "^2.0.0",
"@types/fsevents": "^1.1.0",
"@types/graceful-fs": "^4.1.2",
"@types/invariant": "^2.2.29",
"@types/micromatch": "^3.1.0",
"@types/sane": "^2.0.0"
},
"optionalDependencies": {
"fsevents": "^1.2.9"
"fsevents": "^2.1.2"
},
"engines": {
"node": ">= 8"
Expand Down
20 changes: 11 additions & 9 deletions packages/jest-haste-map/src/lib/FSEventsWatcher.ts
Expand Up @@ -11,7 +11,6 @@ import * as path from 'path';
import {EventEmitter} from 'events';
import anymatch, {Matcher} from 'anymatch';
import micromatch = require('micromatch');
import {Watcher} from 'fsevents';
// @ts-ignore no types
import walker from 'walker';

Expand Down Expand Up @@ -44,7 +43,7 @@ class FSEventsWatcher extends EventEmitter {
public readonly dot: boolean;
public readonly hasIgnore: boolean;
public readonly doIgnore: (path: string) => boolean;
public readonly watcher: Watcher;
public readonly fsEventsWatchStopper: () => Promise<void>;
private _tracked: Set<string>;

static isSupported() {
Expand Down Expand Up @@ -104,9 +103,11 @@ class FSEventsWatcher extends EventEmitter {
this.doIgnore = opts.ignored ? anymatch(opts.ignored) : () => false;

this.root = path.resolve(dir);
this.watcher = fsevents(this.root);
this.fsEventsWatchStopper = fsevents.watch(
this.root,
this.handleEvent.bind(this),
);

this.watcher.start().on('change', this.handleEvent.bind(this));
this._tracked = new Set();
FSEventsWatcher.recReaddir(
this.root,
Expand All @@ -126,11 +127,12 @@ class FSEventsWatcher extends EventEmitter {
* End watching.
*/
close(callback?: () => void) {
this.watcher.stop();
this.removeAllListeners();
if (typeof callback === 'function') {
process.nextTick(callback.bind(null, null, true));
}
this.fsEventsWatchStopper().then(() => {
this.removeAllListeners();
if (typeof callback === 'function') {
process.nextTick(callback.bind(null, null, true));
}
});
}

private isFileIncluded(relativePath: string) {
Expand Down
11 changes: 2 additions & 9 deletions yarn.lock
Expand Up @@ -1906,13 +1906,6 @@
dependencies:
"@types/events" "*"

"@types/fsevents@^1.1.0":
version "1.1.2"
resolved "https://registry.yarnpkg.com/@types/fsevents/-/fsevents-1.1.2.tgz#31f5fcd1abc9a4c9431c03ca60bcac82ba2d05a4"
integrity sha512-obkdv2Yf8rnWYG2WSE5y2ZANP34HMNLAHORgB1m3AiOEA6y8kLJrJDvnTDaZxRDH0iH8mwBYKp18IeOMTYn51Q==
dependencies:
"@types/node" "*"

"@types/glob@*", "@types/glob@^7.1.1":
version "7.1.1"
resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.1.1.tgz#aa59a1c6e3fbc421e07ccd31a944c30eba521575"
Expand Down Expand Up @@ -6513,15 +6506,15 @@ fs.realpath@^1.0.0:
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8=

fsevents@^1.2.3, fsevents@^1.2.7, fsevents@^1.2.9:
fsevents@^1.2.3, fsevents@^1.2.7:
version "1.2.9"
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-1.2.9.tgz#3f5ed66583ccd6f400b5a00db6f7e861363e388f"
integrity sha512-oeyj2H3EjjonWcFjD5NvZNE9Rqe4UW+nQBU2HNeKw0koVLEFIhtyETyAakeAM3de7Z/SW5kcA+fZUait9EApnw==
dependencies:
nan "^2.12.1"
node-pre-gyp "^0.12.0"

fsevents@~2.1.1:
fsevents@^2.1.2, fsevents@~2.1.1:
version "2.1.2"
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.1.2.tgz#4c0a1fb34bc68e543b4b82a9ec392bfbda840805"
integrity sha512-R4wDiBwZ0KzpgOWetKDug1FZcYhqYnUYKtfZYt4mD5SBz76q0KR4Q9o7GIPamsVPGmW3EYPPJ0dOOjvx32ldZA==
Expand Down

0 comments on commit f078d60

Please sign in to comment.