Skip to content

Commit c5b74b0

Browse files
committed
chore: upgrade to micromatch v4 (#8852)
* chore: upgrade to micromatch v4 * fix anymatch namespace issue * use match instead of some * add explicit check for length 0 * more length boolean checks
1 parent 56fe54b commit c5b74b0

File tree

14 files changed

+44
-33
lines changed

14 files changed

+44
-33
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
- `[*]` [**BREAKING**] Drop support for Node 6 ([#8455](https://github.com/facebook/jest/pull/8455))
1515
- `[*]` Add Node 12 to CI ([#8411](https://github.com/facebook/jest/pull/8411))
16+
- `[*]` [**BREAKING**] Upgrade to Micromatch v4 ([#8852](https://github.com/facebook/jest/pull/8852))
1617
- `[docs]` Fix broken link pointing to legacy JS file in "Snapshot Testing".
1718
- `[jest-environment-jsdom]` [**BREAKING**] Upgrade JSDOM from v11 to v15 ([#8851](https://github.com/facebook/jest/pull/8851))
1819

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"karma-webpack": "4.0.0-rc.5",
5656
"left-pad": "^1.1.1",
5757
"lerna": "3.15.0",
58-
"micromatch": "^3.1.10",
58+
"micromatch": "^4.0.2",
5959
"mkdirp": "^0.5.1",
6060
"mocha": "^6.0.2",
6161
"mock-fs": "^4.4.1",

packages/jest-config/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"jest-resolve": "^24.9.0",
2525
"jest-util": "^24.9.0",
2626
"jest-validate": "^24.9.0",
27-
"micromatch": "^3.1.10",
27+
"micromatch": "^4.0.2",
2828
"pretty-format": "^24.9.0",
2929
"realpath-native": "^1.1.0"
3030
},

packages/jest-config/src/normalize.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {Config} from '@jest/types';
1212
import {ValidationError, validate} from 'jest-validate';
1313
import {clearLine, replacePathSepForGlob} from 'jest-util';
1414
import chalk from 'chalk';
15-
import {some as micromatchSome} from 'micromatch';
15+
import micromatch = require('micromatch');
1616
import {sync as realpath} from 'realpath-native';
1717
import Resolver = require('jest-resolve');
1818
import {replacePathSepForRegex} from 'jest-regex-util';
@@ -982,10 +982,10 @@ export default function normalize(
982982
if (newOptions.collectCoverageFrom) {
983983
collectCoverageFrom = collectCoverageFrom.reduce((patterns, filename) => {
984984
if (
985-
!micromatchSome(
986-
replacePathSepForGlob(path.relative(options.rootDir, filename)),
985+
micromatch(
986+
[replacePathSepForGlob(path.relative(options.rootDir, filename))],
987987
newOptions.collectCoverageFrom!,
988-
)
988+
).length === 0
989989
) {
990990
return patterns;
991991
}

packages/jest-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"jest-util": "^24.9.0",
2828
"jest-validate": "^24.9.0",
2929
"jest-watcher": "^24.9.0",
30-
"micromatch": "^3.1.10",
30+
"micromatch": "^4.0.2",
3131
"p-each-series": "^1.0.0",
3232
"realpath-native": "^1.1.0",
3333
"rimraf": "^2.5.4",

packages/jest-core/src/SearchSource.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
import * as path from 'path';
9-
import {some as micromatchSome} from 'micromatch';
9+
import micromatch = require('micromatch');
1010
import {Context} from 'jest-runtime';
1111
import {Config} from '@jest/types';
1212
import {Test} from 'jest-runner';
@@ -37,7 +37,7 @@ export type TestSelectionConfig = {
3737
};
3838

3939
const globsToMatcher = (globs: Array<Config.Glob>) => (path: Config.Path) =>
40-
micromatchSome(replacePathSepForGlob(path), globs, {dot: true});
40+
micromatch([replacePathSepForGlob(path)], globs, {dot: true}).length > 0;
4141

4242
const regexToMatcher = (testRegex: Array<string>) => (path: Config.Path) =>
4343
testRegex.some(testRegex => new RegExp(testRegex).test(path));

packages/jest-haste-map/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
"types": "build/index.d.ts",
1212
"dependencies": {
1313
"@jest/types": "^24.9.0",
14-
"anymatch": "^2.0.0",
14+
"anymatch": "^3.0.3",
1515
"fb-watchman": "^2.0.0",
1616
"graceful-fs": "^4.1.15",
1717
"invariant": "^2.2.4",
1818
"jest-serializer": "^24.9.0",
1919
"jest-util": "^24.9.0",
2020
"jest-worker": "^24.9.0",
21-
"micromatch": "^3.1.10",
21+
"micromatch": "^4.0.2",
2222
"sane": "^4.0.3",
2323
"walker": "^1.0.7"
2424
},

packages/jest-haste-map/src/HasteFS.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import {some as micromatchSome} from 'micromatch';
8+
import micromatch = require('micromatch');
99
import {replacePathSepForGlob} from 'jest-util';
1010
import {Config} from '@jest/types';
1111
import {FileData} from './types';
@@ -86,7 +86,7 @@ export default class HasteFS {
8686
const files = new Set<string>();
8787
for (const file of this.getAbsoluteFileIterator()) {
8888
const filePath = root ? fastPath.relative(root, file) : file;
89-
if (micromatchSome(replacePathSepForGlob(filePath), globs)) {
89+
if (micromatch([replacePathSepForGlob(filePath)], globs).length > 0) {
9090
files.add(file);
9191
}
9292
}

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
import * as fs from 'fs';
1010
import * as path from 'path';
1111
import {EventEmitter} from 'events';
12-
import anymatch = require('anymatch');
13-
import {some as micromatchSome} from 'micromatch';
12+
import anymatch, {Matcher} from 'anymatch';
13+
import micromatch = require('micromatch');
1414
// eslint-disable-next-line
1515
import {Watcher} from 'fsevents';
1616
// @ts-ignore no types
@@ -40,7 +40,7 @@ type FsEventsWatcherEvent =
4040
*/
4141
class FSEventsWatcher extends EventEmitter {
4242
public readonly root: string;
43-
public readonly ignored?: anymatch.Matcher;
43+
public readonly ignored?: Matcher;
4444
public readonly glob: Array<string>;
4545
public readonly dot: boolean;
4646
public readonly hasIgnore: boolean;
@@ -65,7 +65,7 @@ class FSEventsWatcher extends EventEmitter {
6565
fileCallback: (normalizedPath: string, stats: fs.Stats) => void,
6666
endCallback: Function,
6767
errorCallback: Function,
68-
ignored?: anymatch.Matcher,
68+
ignored?: Matcher,
6969
) {
7070
walker(dir)
7171
.filterDir(
@@ -83,7 +83,7 @@ class FSEventsWatcher extends EventEmitter {
8383
dir: string,
8484
opts: {
8585
root: string;
86-
ignored?: anymatch.Matcher;
86+
ignored?: Matcher;
8787
glob: string | Array<string>;
8888
dot: boolean;
8989
},
@@ -139,8 +139,8 @@ class FSEventsWatcher extends EventEmitter {
139139
return false;
140140
}
141141
return this.glob.length
142-
? micromatchSome(relativePath, this.glob, {dot: this.dot})
143-
: this.dot || micromatchSome(relativePath, '**/*');
142+
? micromatch([relativePath], this.glob, {dot: this.dot}).length > 0
143+
: this.dot || micromatch([relativePath], '**/*').length > 0;
144144
}
145145

146146
private handleEvent(filepath: string) {

packages/jest-message-util/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"@jest/types": "^24.9.0",
1919
"@types/stack-utils": "^1.0.1",
2020
"chalk": "^2.0.1",
21-
"micromatch": "^3.1.10",
21+
"micromatch": "^4.0.2",
2222
"slash": "^2.0.0",
2323
"stack-utils": "^1.0.1"
2424
},

0 commit comments

Comments
 (0)