Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade to micromatch v4 #8852

Merged
merged 5 commits into from
Aug 19, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

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

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"karma-webpack": "4.0.0-rc.5",
"left-pad": "^1.1.1",
"lerna": "3.15.0",
"micromatch": "^3.1.10",
"micromatch": "^4.0.2",
"mkdirp": "^0.5.1",
"mocha": "^6.0.2",
"mock-fs": "^4.4.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"jest-resolve": "^24.9.0",
"jest-util": "^24.9.0",
"jest-validate": "^24.9.0",
"micromatch": "^3.1.10",
"micromatch": "^4.0.2",
"pretty-format": "^24.9.0",
"realpath-native": "^1.1.0"
},
Expand Down
8 changes: 4 additions & 4 deletions packages/jest-config/src/normalize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {Config} from '@jest/types';
import {ValidationError, validate} from 'jest-validate';
import {clearLine, replacePathSepForGlob} from 'jest-util';
import chalk from 'chalk';
import {some as micromatchSome} from 'micromatch';
import micromatch from 'micromatch';
import {sync as realpath} from 'realpath-native';
import Resolver from 'jest-resolve';
import {replacePathSepForRegex} from 'jest-regex-util';
Expand Down Expand Up @@ -982,10 +982,10 @@ export default function normalize(
if (newOptions.collectCoverageFrom) {
collectCoverageFrom = collectCoverageFrom.reduce((patterns, filename) => {
if (
!micromatchSome(
replacePathSepForGlob(path.relative(options.rootDir, filename)),
micromatch(
[replacePathSepForGlob(path.relative(options.rootDir, filename))],
newOptions.collectCoverageFrom!,
)
).length === 0
) {
return patterns;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"jest-util": "^24.9.0",
"jest-validate": "^24.9.0",
"jest-watcher": "^24.9.0",
"micromatch": "^3.1.10",
"micromatch": "^4.0.2",
"p-each-series": "^1.0.0",
"realpath-native": "^1.1.0",
"rimraf": "^2.5.4",
Expand Down
4 changes: 2 additions & 2 deletions packages/jest-core/src/SearchSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import * as path from 'path';
import {some as micromatchSome} from 'micromatch';
import micromatch from 'micromatch';
import {Context} from 'jest-runtime';
import {Config} from '@jest/types';
import {Test} from 'jest-runner';
Expand Down Expand Up @@ -37,7 +37,7 @@ export type TestSelectionConfig = {
};

const globsToMatcher = (globs: Array<Config.Glob>) => (path: Config.Path) =>
micromatchSome(replacePathSepForGlob(path), globs, {dot: true});
!!micromatch([replacePathSepForGlob(path)], globs, {dot: true}).length;
thymikee marked this conversation as resolved.
Show resolved Hide resolved

const regexToMatcher = (testRegex: Array<string>) => (path: Config.Path) =>
testRegex.some(testRegex => new RegExp(testRegex).test(path));
Expand Down
4 changes: 2 additions & 2 deletions packages/jest-haste-map/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
"types": "build/index.d.ts",
"dependencies": {
"@jest/types": "^24.9.0",
"anymatch": "^2.0.0",
"anymatch": "^3.0.3",
"fb-watchman": "^2.0.0",
"graceful-fs": "^4.1.15",
"invariant": "^2.2.4",
"jest-serializer": "^24.9.0",
"jest-util": "^24.9.0",
"jest-worker": "^24.9.0",
"micromatch": "^3.1.10",
"micromatch": "^4.0.2",
"sane": "^4.0.3",
"walker": "^1.0.7"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/jest-haste-map/src/HasteFS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

import {some as micromatchSome} from 'micromatch';
import micromatch from 'micromatch';
import {replacePathSepForGlob} from 'jest-util';
import {Config} from '@jest/types';
import {FileData} from './types';
Expand Down Expand Up @@ -86,7 +86,7 @@ export default class HasteFS {
const files = new Set<string>();
for (const file of this.getAbsoluteFileIterator()) {
const filePath = root ? fastPath.relative(root, file) : file;
if (micromatchSome(replacePathSepForGlob(filePath), globs)) {
if (micromatch([replacePathSepForGlob(filePath)], globs).length) {
files.add(file);
}
}
Expand Down
14 changes: 7 additions & 7 deletions packages/jest-haste-map/src/lib/FSEventsWatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import * as fs from 'fs';
import * as path from 'path';
import {EventEmitter} from 'events';
import anymatch from 'anymatch';
import {some as micromatchSome} from 'micromatch';
import anymatch, {Matcher} from 'anymatch';
import micromatch from 'micromatch';
// eslint-disable-next-line
import {Watcher} from 'fsevents';
// @ts-ignore no types
Expand Down Expand Up @@ -40,7 +40,7 @@ type FsEventsWatcherEvent =
*/
class FSEventsWatcher extends EventEmitter {
public readonly root: string;
public readonly ignored?: anymatch.Matcher;
public readonly ignored?: Matcher;
public readonly glob: Array<string>;
public readonly dot: boolean;
public readonly hasIgnore: boolean;
Expand All @@ -65,7 +65,7 @@ class FSEventsWatcher extends EventEmitter {
fileCallback: (normalizedPath: string, stats: fs.Stats) => void,
endCallback: Function,
errorCallback: Function,
ignored?: anymatch.Matcher,
ignored?: Matcher,
) {
walker(dir)
.filterDir(
Expand All @@ -83,7 +83,7 @@ class FSEventsWatcher extends EventEmitter {
dir: string,
opts: {
root: string;
ignored?: anymatch.Matcher;
ignored?: Matcher;
glob: string | Array<string>;
dot: boolean;
},
Expand Down Expand Up @@ -139,8 +139,8 @@ class FSEventsWatcher extends EventEmitter {
return false;
}
return this.glob.length
? micromatchSome(relativePath, this.glob, {dot: this.dot})
: this.dot || micromatchSome(relativePath, '**/*');
? !!micromatch([relativePath], this.glob, {dot: this.dot}).length
: !!this.dot || micromatch([relativePath], '**/*').length;
}

private handleEvent(filepath: string) {
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-message-util/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@jest/types": "^24.9.0",
"@types/stack-utils": "^1.0.1",
"chalk": "^2.0.1",
"micromatch": "^3.1.10",
"micromatch": "^4.0.2",
"slash": "^2.0.0",
"stack-utils": "^1.0.1"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/jest-message-util/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as path from 'path';
import {Config} from '@jest/types';
import {AssertionResult, SerializableError} from '@jest/test-result';
import chalk from 'chalk';
import {some as micromatchSome} from 'micromatch';
import micromatch from 'micromatch';
import slash from 'slash';
import {codeFrameColumns} from '@babel/code-frame';
import StackUtils from 'stack-utils';
Expand Down Expand Up @@ -216,7 +216,7 @@ const formatPaths = (
if (
(config.testMatch &&
config.testMatch.length &&
micromatchSome(filePath, config.testMatch)) ||
micromatch([filePath], config.testMatch).length) ||
filePath === relativeTestPath
) {
filePath = chalk.reset.cyan(filePath);
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-transform/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"jest-haste-map": "^24.9.0",
"jest-regex-util": "^24.9.0",
"jest-util": "^24.9.0",
"micromatch": "^3.1.10",
"micromatch": "^4.0.2",
"pirates": "^4.0.1",
"realpath-native": "^1.1.0",
"slash": "^2.0.0",
Expand Down
12 changes: 7 additions & 5 deletions packages/jest-transform/src/shouldInstrument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import * as path from 'path';
import {Config} from '@jest/types';
import {escapePathForRegex} from 'jest-regex-util';
import {replacePathSepForGlob} from 'jest-util';
import {any as micromatchAny, some as micromatchSome} from 'micromatch';
import micromatch, {any as micromatchAny} from 'micromatch';
import {ShouldInstrumentOptions} from './types';

const MOCKS_PATTERN = new RegExp(
Expand Down Expand Up @@ -39,7 +39,9 @@ export default function shouldInstrument(
return false;
}

if (micromatchSome(replacePathSepForGlob(filename), config.testMatch)) {
if (
micromatch([replacePathSepForGlob(filename)], config.testMatch).length
) {
return false;
}
}
Expand All @@ -57,10 +59,10 @@ export default function shouldInstrument(
// still cover if `only` is specified
!options.collectCoverageOnlyFrom &&
options.collectCoverageFrom &&
!micromatchSome(
replacePathSepForGlob(path.relative(config.rootDir, filename)),
!micromatch(
[replacePathSepForGlob(path.relative(config.rootDir, filename))],
options.collectCoverageFrom,
)
).length
) {
return false;
}
Expand Down
14 changes: 11 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3009,7 +3009,7 @@ anymatch@^2.0.0:
micromatch "^3.1.4"
normalize-path "^2.1.1"

anymatch@^3.0.1:
anymatch@^3.0.1, anymatch@^3.0.3:
version "3.0.3"
resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.0.3.tgz#2fb624fe0e84bccab00afee3d0006ed310f22f09"
integrity sha512-c6IvoeBECQlMVuYUjSwimnhmztImpErfxJzWZhIQinIvQWoGOnB0dLIgifbPHQt5heS6mNlaZG16f06H3C8t1g==
Expand Down Expand Up @@ -3728,7 +3728,7 @@ braces@^2.3.1, braces@^2.3.2:
split-string "^3.0.2"
to-regex "^3.0.1"

braces@^3.0.2:
braces@^3.0.1, braces@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107"
integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==
Expand Down Expand Up @@ -9614,6 +9614,14 @@ micromatch@^3.1.10, micromatch@^3.1.4, micromatch@^3.1.8:
snapdragon "^0.8.1"
to-regex "^3.0.2"

micromatch@^4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.2.tgz#4fcb0999bf9fbc2fcbdd212f6d629b9a56c39259"
integrity sha512-y7FpHSbMUMoyPbYUSzO6PaZ6FyRnQOpHuKwbo1G+Knck95XVU4QAiKdGEnj5wwoS7PlOgthX/09u5iFJ+aYf5Q==
dependencies:
braces "^3.0.1"
picomatch "^2.0.5"

miller-rabin@^4.0.0:
version "4.0.1"
resolved "https://registry.yarnpkg.com/miller-rabin/-/miller-rabin-4.0.1.tgz#f080351c865b0dc562a8462966daa53543c78a4d"
Expand Down Expand Up @@ -10864,7 +10872,7 @@ performance-now@^2.1.0:
resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"
integrity sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=

picomatch@^2.0.4:
picomatch@^2.0.4, picomatch@^2.0.5:
version "2.0.7"
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.0.7.tgz#514169d8c7cd0bdbeecc8a2609e34a7163de69f6"
integrity sha512-oLHIdio3tZ0qH76NybpeneBhYVj0QFTfXEFTc/B3zKQspYfYYkWYgFsmzo+4kvId/bQRcNkVeguI3y+CD22BtA==
Expand Down