Skip to content

Commit f078d60

Browse files
committed
chore: upgrade to fsevents 2
1 parent be6df92 commit f078d60

File tree

4 files changed

+15
-20
lines changed

4 files changed

+15
-20
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
- `[jest-cli]` [**BREAKING**] Remove re-exports from `@jest/core` ([#8874](https://github.com/facebook/jest/pull/8874))
7777
- `[jest-diff]` Remove the need to export `splitLines0` function ([#9151](https://github.com/facebook/jest/pull/9151))
7878
- `[jest-environment-jsdom]` [**BREAKING**] Upgrade JSDOM from v11 to v15 ([#8851](https://github.com/facebook/jest/pull/8851))
79+
- `[jest-haste-map]` Upgrade to `fsevents@2` ([#9215](https://github.com/facebook/jest/pull/9215))
7980
- `[jest-util]` [**BREAKING**] Remove deprecated exports ([#8863](https://github.com/facebook/jest/pull/8863))
8081
- `[jest-validate]` [**BREAKING**] Use ESM exports ([#8874](https://github.com/facebook/jest/pull/8874))
8182
- `[jest-types]` Mark `InitialOptions` as `Partial` ([#8848](https://github.com/facebook/jest/pull/8848))

packages/jest-haste-map/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,13 @@
2525
"devDependencies": {
2626
"@types/anymatch": "^1.3.1",
2727
"@types/fb-watchman": "^2.0.0",
28-
"@types/fsevents": "^1.1.0",
2928
"@types/graceful-fs": "^4.1.2",
3029
"@types/invariant": "^2.2.29",
3130
"@types/micromatch": "^3.1.0",
3231
"@types/sane": "^2.0.0"
3332
},
3433
"optionalDependencies": {
35-
"fsevents": "^1.2.9"
34+
"fsevents": "^2.1.2"
3635
},
3736
"engines": {
3837
"node": ">= 8"

packages/jest-haste-map/src/lib/FSEventsWatcher.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import * as path from 'path';
1111
import {EventEmitter} from 'events';
1212
import anymatch, {Matcher} from 'anymatch';
1313
import micromatch = require('micromatch');
14-
import {Watcher} from 'fsevents';
1514
// @ts-ignore no types
1615
import walker from 'walker';
1716

@@ -44,7 +43,7 @@ class FSEventsWatcher extends EventEmitter {
4443
public readonly dot: boolean;
4544
public readonly hasIgnore: boolean;
4645
public readonly doIgnore: (path: string) => boolean;
47-
public readonly watcher: Watcher;
46+
public readonly fsEventsWatchStopper: () => Promise<void>;
4847
private _tracked: Set<string>;
4948

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

106105
this.root = path.resolve(dir);
107-
this.watcher = fsevents(this.root);
106+
this.fsEventsWatchStopper = fsevents.watch(
107+
this.root,
108+
this.handleEvent.bind(this),
109+
);
108110

109-
this.watcher.start().on('change', this.handleEvent.bind(this));
110111
this._tracked = new Set();
111112
FSEventsWatcher.recReaddir(
112113
this.root,
@@ -126,11 +127,12 @@ class FSEventsWatcher extends EventEmitter {
126127
* End watching.
127128
*/
128129
close(callback?: () => void) {
129-
this.watcher.stop();
130-
this.removeAllListeners();
131-
if (typeof callback === 'function') {
132-
process.nextTick(callback.bind(null, null, true));
133-
}
130+
this.fsEventsWatchStopper().then(() => {
131+
this.removeAllListeners();
132+
if (typeof callback === 'function') {
133+
process.nextTick(callback.bind(null, null, true));
134+
}
135+
});
134136
}
135137

136138
private isFileIncluded(relativePath: string) {

yarn.lock

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1906,13 +1906,6 @@
19061906
dependencies:
19071907
"@types/events" "*"
19081908

1909-
"@types/fsevents@^1.1.0":
1910-
version "1.1.2"
1911-
resolved "https://registry.yarnpkg.com/@types/fsevents/-/fsevents-1.1.2.tgz#31f5fcd1abc9a4c9431c03ca60bcac82ba2d05a4"
1912-
integrity sha512-obkdv2Yf8rnWYG2WSE5y2ZANP34HMNLAHORgB1m3AiOEA6y8kLJrJDvnTDaZxRDH0iH8mwBYKp18IeOMTYn51Q==
1913-
dependencies:
1914-
"@types/node" "*"
1915-
19161909
"@types/glob@*", "@types/glob@^7.1.1":
19171910
version "7.1.1"
19181911
resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.1.1.tgz#aa59a1c6e3fbc421e07ccd31a944c30eba521575"
@@ -6513,15 +6506,15 @@ fs.realpath@^1.0.0:
65136506
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
65146507
integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8=
65156508

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

6524-
fsevents@~2.1.1:
6517+
fsevents@^2.1.2, fsevents@~2.1.1:
65256518
version "2.1.2"
65266519
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.1.2.tgz#4c0a1fb34bc68e543b4b82a9ec392bfbda840805"
65276520
integrity sha512-R4wDiBwZ0KzpgOWetKDug1FZcYhqYnUYKtfZYt4mD5SBz76q0KR4Q9o7GIPamsVPGmW3EYPPJ0dOOjvx32ldZA==

0 commit comments

Comments
 (0)