Skip to content

Commit df07611

Browse files
authored
fix: replace micromatch with picomatch (#7951)
1 parent ba6da4d commit df07611

File tree

9 files changed

+31
-210
lines changed

9 files changed

+31
-210
lines changed

packages/vitest/LICENSE.md

Lines changed: 0 additions & 174 deletions
Original file line numberDiff line numberDiff line change
@@ -170,35 +170,6 @@ Repository: git+https://github.com/antfu/birpc.git
170170
171171
---------------------------------------
172172

173-
## braces
174-
License: MIT
175-
By: Jon Schlinkert, Brian Woodward, Elan Shanker, Eugene Sharygin, hemanth.hm
176-
Repository: micromatch/braces
177-
178-
> The MIT License (MIT)
179-
>
180-
> Copyright (c) 2014-present, Jon Schlinkert.
181-
>
182-
> Permission is hereby granted, free of charge, to any person obtaining a copy
183-
> of this software and associated documentation files (the "Software"), to deal
184-
> in the Software without restriction, including without limitation the rights
185-
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
186-
> copies of the Software, and to permit persons to whom the Software is
187-
> furnished to do so, subject to the following conditions:
188-
>
189-
> The above copyright notice and this permission notice shall be included in
190-
> all copies or substantial portions of the Software.
191-
>
192-
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
193-
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
194-
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
195-
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
196-
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
197-
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
198-
> THE SOFTWARE.
199-
200-
---------------------------------------
201-
202173
## cac
203174
License: MIT
204175
By: egoist
@@ -257,35 +228,6 @@ Repository: https://github.com/debitoor/chai-subset.git
257228
258229
---------------------------------------
259230

260-
## fill-range
261-
License: MIT
262-
By: Jon Schlinkert, Edo Rivai, Paul Miller, Rouven Weßling
263-
Repository: jonschlinkert/fill-range
264-
265-
> The MIT License (MIT)
266-
>
267-
> Copyright (c) 2014-present, Jon Schlinkert.
268-
>
269-
> Permission is hereby granted, free of charge, to any person obtaining a copy
270-
> of this software and associated documentation files (the "Software"), to deal
271-
> in the Software without restriction, including without limitation the rights
272-
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
273-
> copies of the Software, and to permit persons to whom the Software is
274-
> furnished to do so, subject to the following conditions:
275-
>
276-
> The above copyright notice and this permission notice shall be included in
277-
> all copies or substantial portions of the Software.
278-
>
279-
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
280-
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
281-
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
282-
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
283-
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
284-
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
285-
> THE SOFTWARE.
286-
287-
---------------------------------------
288-
289231
## find-up
290232
License: MIT
291233
By: Sindre Sorhus
@@ -355,35 +297,6 @@ Repository: privatenumber/get-tsconfig
355297
356298
---------------------------------------
357299

358-
## is-number
359-
License: MIT
360-
By: Jon Schlinkert, Olsten Larck, Rouven Weßling
361-
Repository: jonschlinkert/is-number
362-
363-
> The MIT License (MIT)
364-
>
365-
> Copyright (c) 2014-present, Jon Schlinkert.
366-
>
367-
> Permission is hereby granted, free of charge, to any person obtaining a copy
368-
> of this software and associated documentation files (the "Software"), to deal
369-
> in the Software without restriction, including without limitation the rights
370-
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
371-
> copies of the Software, and to permit persons to whom the Software is
372-
> furnished to do so, subject to the following conditions:
373-
>
374-
> The above copyright notice and this permission notice shall be included in
375-
> all copies or substantial portions of the Software.
376-
>
377-
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
378-
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
379-
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
380-
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
381-
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
382-
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
383-
> THE SOFTWARE.
384-
385-
---------------------------------------
386-
387300
## js-tokens
388301
License: MIT
389302
By: Simon Lydell
@@ -488,35 +401,6 @@ Repository: sindresorhus/locate-path
488401
489402
---------------------------------------
490403

491-
## micromatch
492-
License: MIT
493-
By: Jon Schlinkert, Amila Welihinda, Bogdan Chadkin, Brian Woodward, Devon Govett, Elan Shanker, Fabrício Matté, Martin Kolárik, Olsten Larck, Paul Miller, Tom Byrer, Tyler Akins, Peter Bright, Kuba Juszczyk
494-
Repository: micromatch/micromatch
495-
496-
> The MIT License (MIT)
497-
>
498-
> Copyright (c) 2014-present, Jon Schlinkert.
499-
>
500-
> Permission is hereby granted, free of charge, to any person obtaining a copy
501-
> of this software and associated documentation files (the "Software"), to deal
502-
> in the Software without restriction, including without limitation the rights
503-
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
504-
> copies of the Software, and to permit persons to whom the Software is
505-
> furnished to do so, subject to the following conditions:
506-
>
507-
> The above copyright notice and this permission notice shall be included in
508-
> all copies or substantial portions of the Software.
509-
>
510-
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
511-
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
512-
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
513-
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
514-
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
515-
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
516-
> THE SOFTWARE.
517-
518-
---------------------------------------
519-
520404
## mlly
521405
License: MIT
522406
Repository: unjs/mlly
@@ -608,35 +492,6 @@ Repository: git+https://github.com/antfu-collective/package-manager-detector.git
608492
609493
---------------------------------------
610494

611-
## picomatch
612-
License: MIT
613-
By: Jon Schlinkert
614-
Repository: micromatch/picomatch
615-
616-
> The MIT License (MIT)
617-
>
618-
> Copyright (c) 2017-present, Jon Schlinkert.
619-
>
620-
> Permission is hereby granted, free of charge, to any person obtaining a copy
621-
> of this software and associated documentation files (the "Software"), to deal
622-
> in the Software without restriction, including without limitation the rights
623-
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
624-
> copies of the Software, and to permit persons to whom the Software is
625-
> furnished to do so, subject to the following conditions:
626-
>
627-
> The above copyright notice and this permission notice shall be included in
628-
> all copies or substantial portions of the Software.
629-
>
630-
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
631-
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
632-
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
633-
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
634-
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
635-
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
636-
> THE SOFTWARE.
637-
638-
---------------------------------------
639-
640495
## prompts
641496
License: MIT
642497
By: Terkel Gjervig
@@ -782,35 +637,6 @@ Repository: git+https://github.com/antfu/strip-literal.git
782637
783638
---------------------------------------
784639

785-
## to-regex-range
786-
License: MIT
787-
By: Jon Schlinkert, Rouven Weßling
788-
Repository: micromatch/to-regex-range
789-
790-
> The MIT License (MIT)
791-
>
792-
> Copyright (c) 2015-present, Jon Schlinkert.
793-
>
794-
> Permission is hereby granted, free of charge, to any person obtaining a copy
795-
> of this software and associated documentation files (the "Software"), to deal
796-
> in the Software without restriction, including without limitation the rights
797-
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
798-
> copies of the Software, and to permit persons to whom the Software is
799-
> furnished to do so, subject to the following conditions:
800-
>
801-
> The above copyright notice and this permission notice shall be included in
802-
> all copies or substantial portions of the Software.
803-
>
804-
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
805-
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
806-
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
807-
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
808-
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
809-
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
810-
> THE SOFTWARE.
811-
812-
---------------------------------------
813-
814640
## type-detect
815641
License: MIT
816642
By: Jake Luer, Keith Cirkel, David Losert, Aleksey Shvayka, Lucas Fernandes da Costa, Grant Snodgrass, Jeremy Tice, Edward Betts, dvlsg, Amila Welihinda, Jake Champion, Miroslav Bajtoš

packages/vitest/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@
167167
"expect-type": "^1.2.1",
168168
"magic-string": "catalog:",
169169
"pathe": "catalog:",
170+
"picomatch": "^4.0.2",
170171
"std-env": "catalog:",
171172
"tinybench": "^2.9.0",
172173
"tinyexec": "^0.3.2",
@@ -187,8 +188,8 @@
187188
"@types/istanbul-lib-coverage": "catalog:",
188189
"@types/istanbul-reports": "catalog:",
189190
"@types/jsdom": "^21.1.7",
190-
"@types/micromatch": "^4.0.9",
191191
"@types/node": "^22.14.1",
192+
"@types/picomatch": "^4.0.0",
192193
"@types/prompts": "^2.4.9",
193194
"@types/sinonjs__fake-timers": "^8.1.5",
194195
"acorn-walk": "catalog:",
@@ -201,7 +202,6 @@
201202
"happy-dom": "^17.4.4",
202203
"jsdom": "^26.1.0",
203204
"local-pkg": "^1.1.1",
204-
"micromatch": "^4.0.8",
205205
"pretty-format": "^29.7.0",
206206
"prompts": "^2.4.2",
207207
"strip-literal": "^3.0.0",

packages/vitest/src/node/coverage.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import type { BaseCoverageOptions, CoverageModuleLoader, CoverageProvider, Repor
55
import type { SerializedCoverageConfig } from '../runtime/config'
66
import type { AfterSuiteRunMeta } from '../types/general'
77
import { existsSync, promises as fs, readdirSync, writeFileSync } from 'node:fs'
8-
import mm from 'micromatch'
98
import { relative, resolve } from 'pathe'
9+
import pm from 'picomatch'
1010
import c from 'tinyrainbow'
1111
import { coverageConfigDefaults } from '../defaults'
1212
import { resolveCoverageReporters } from '../node/config/resolveConfig'
@@ -316,8 +316,9 @@ export class BaseCoverageProvider<Options extends ResolvedCoverageOptions<'istan
316316
const globThresholds = resolveGlobThresholds(this.options.thresholds![glob])
317317
const globCoverageMap = this.createCoverageMap()
318318

319+
const matcher = pm(glob)
319320
const matchingFiles = files.filter(file =>
320-
mm.isMatch(relative(this.ctx.config.root, file), glob),
321+
matcher(relative(this.ctx.config.root, file)),
321322
)
322323

323324
for (const file of matchingFiles) {

packages/vitest/src/node/pool.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { TestProject } from './project'
44
import type { TestSpecification } from './spec'
55
import type { BuiltinPool, Pool } from './types/pool-options'
66
import { isatty } from 'node:tty'
7-
import mm from 'micromatch'
7+
import pm from 'picomatch'
88
import { version as viteVersion } from 'vite'
99
import { isWindows } from '../utils/env'
1010
import { createForksPool } from './pools/forks'
@@ -73,7 +73,7 @@ export function getFilePoolName(project: TestProject, file: string): Pool {
7373
'Since Vitest 0.31.0 "browser" pool is not supported in "poolMatchGlobs". You can create a project to run some of your tests in browser in parallel. Read more: https://vitest.dev/guide/projects',
7474
)
7575
}
76-
if (mm.isMatch(file, glob, { cwd: project.config.root })) {
76+
if (pm.isMatch(file, glob, { cwd: project.config.root })) {
7777
return pool as Pool
7878
}
7979
}

packages/vitest/src/node/project.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ import { rm } from 'node:fs/promises'
2525
import { tmpdir } from 'node:os'
2626
import path from 'node:path'
2727
import { deepMerge, nanoid, slash } from '@vitest/utils'
28-
import mm from 'micromatch'
2928
import { isAbsolute, join, relative } from 'pathe'
29+
import pm from 'picomatch'
3030
import { glob } from 'tinyglobby'
3131
import { ViteNodeRunner } from 'vite-node/client'
3232
import { ViteNodeServer } from 'vite-node/server'
@@ -453,16 +453,16 @@ export class TestProject {
453453
return true
454454
}
455455
const relativeId = relative(this.config.dir || this.config.root, moduleId)
456-
if (mm.isMatch(relativeId, this.config.exclude)) {
456+
if (pm.isMatch(relativeId, this.config.exclude)) {
457457
return false
458458
}
459-
if (mm.isMatch(relativeId, this.config.include)) {
459+
if (pm.isMatch(relativeId, this.config.include)) {
460460
this.markTestFile(moduleId)
461461
return true
462462
}
463463
if (
464464
this.config.includeSource?.length
465-
&& mm.isMatch(relativeId, this.config.includeSource)
465+
&& pm.isMatch(relativeId, this.config.includeSource)
466466
) {
467467
const code = source?.() || readFileSync(moduleId, 'utf-8')
468468
if (this.isInSourceTestCode(code)) {

packages/vitest/src/node/specifications.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import type { Vitest } from './core'
22
import type { TestProject } from './project'
33
import type { TestSpecification } from './spec'
44
import { existsSync } from 'node:fs'
5-
import mm from 'micromatch'
65
import { join, relative, resolve } from 'pathe'
6+
import pm from 'picomatch'
77
import { isWindows } from '../utils/env'
88
import { groupFilters, parseFilter } from './cli/filter'
99
import { GitNotFoundError, IncludeTaskLocationDisabledError, LocationFilterFileNotFoundError } from './errors'
@@ -139,7 +139,8 @@ export class VitestSpecifications {
139139
}
140140

141141
const forceRerunTriggers = this.vitest.config.forceRerunTriggers
142-
if (forceRerunTriggers.length && mm(related, forceRerunTriggers).length) {
142+
const matcher = forceRerunTriggers.length ? pm(forceRerunTriggers) : undefined
143+
if (matcher && related.some(file => matcher(file))) {
143144
return specs
144145
}
145146

packages/vitest/src/node/watcher.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import type { Vitest } from './core'
22
import type { TestProject } from './project'
33
import { readFileSync } from 'node:fs'
44
import { noop, slash } from '@vitest/utils'
5-
import mm from 'micromatch'
65
import { resolve } from 'pathe'
6+
import pm from 'picomatch'
77

88
export class VitestWatcher {
99
/**
@@ -148,7 +148,7 @@ export class VitestWatcher {
148148
return false
149149
}
150150

151-
if (mm.isMatch(filepath, this.vitest.config.forceRerunTriggers)) {
151+
if (pm.isMatch(filepath, this.vitest.config.forceRerunTriggers)) {
152152
this.vitest.state.getFilepaths().forEach(file => this.changedTests.add(file))
153153
return true
154154
}

packages/vitest/src/utils/test-helpers.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { TestSpecification } from '../node/spec'
33
import type { EnvironmentOptions, TransformModePatterns, VitestEnvironment } from '../node/types/config'
44
import type { ContextTestEnvironment } from '../types/worker'
55
import { promises as fs } from 'node:fs'
6-
import mm from 'micromatch'
6+
import pm from 'picomatch'
77
import { groupBy } from './base'
88

99
export const envsOrder: string[] = ['node', 'jsdom', 'happy-dom', 'edge-runtime']
@@ -18,10 +18,10 @@ function getTransformMode(
1818
patterns: TransformModePatterns,
1919
filename: string,
2020
): 'web' | 'ssr' | undefined {
21-
if (patterns.web && mm.isMatch(filename, patterns.web)) {
21+
if (patterns.web && pm.isMatch(filename, patterns.web)) {
2222
return 'web'
2323
}
24-
if (patterns.ssr && mm.isMatch(filename, patterns.ssr)) {
24+
if (patterns.ssr && pm.isMatch(filename, patterns.ssr)) {
2525
return 'ssr'
2626
}
2727
return undefined
@@ -44,7 +44,7 @@ export async function groupFilesByEnv(
4444
if (!env) {
4545
for (const [glob, target] of project.config.environmentMatchGlobs
4646
|| []) {
47-
if (mm.isMatch(filepath, glob, { cwd: project.config.root })) {
47+
if (pm.isMatch(filepath, glob, { cwd: project.config.root })) {
4848
env = target
4949
break
5050
}

0 commit comments

Comments
 (0)