|
1 | 1 | import path from 'node:path' |
2 | 2 |
|
3 | | -import micromatch from 'micromatch' |
| 3 | +import picomatch from 'picomatch' |
4 | 4 |
|
5 | 5 | import { createDebug } from './debug.js' |
6 | 6 | import { normalizePath } from './normalizePath.js' |
@@ -35,31 +35,23 @@ export const generateTasks = ({ config, cwd = process.cwd(), files, relative = f |
35 | 35 | return !file.filepath.startsWith('..') && !path.isAbsolute(file.filepath) |
36 | 36 | }) |
37 | 37 |
|
38 | | - const matches = micromatch( |
39 | | - filteredFiles.map((file) => file.filepath), |
40 | | - pattern, |
41 | | - { |
42 | | - cwd, |
43 | | - dot: true, |
44 | | - // If the pattern doesn't look like a path, enable `matchBase` to |
45 | | - // match against filenames in every directory. This makes `*.js` |
46 | | - // match both `test.js` and `subdirectory/test.js`. |
47 | | - matchBase: !pattern.includes('/'), |
48 | | - posixSlashes: true, |
49 | | - strictBrackets: true, |
50 | | - } |
51 | | - ) |
| 38 | + const isMatch = picomatch(pattern, { |
| 39 | + cwd, |
| 40 | + dot: true, |
| 41 | + // If the pattern doesn't look like a path, enable `matchBase` to |
| 42 | + // match against filenames in every directory. This makes `*.js` |
| 43 | + // match both `test.js` and `subdirectory/test.js`. |
| 44 | + matchBase: !pattern.includes('/'), |
| 45 | + posixSlashes: true, |
| 46 | + strictBrackets: true, |
| 47 | + }) |
52 | 48 |
|
53 | | - const fileList = filteredFiles.flatMap((file) => |
54 | | - matches.includes(file.filepath) |
55 | | - ? [ |
56 | | - { |
57 | | - filepath: normalizePath(relative ? file.filepath : path.resolve(cwd, file.filepath)), |
58 | | - status: file.status, |
59 | | - }, |
60 | | - ] |
61 | | - : [] |
62 | | - ) |
| 49 | + const fileList = filteredFiles |
| 50 | + .filter((file) => isMatch(file.filepath)) |
| 51 | + .map((file) => ({ |
| 52 | + filepath: normalizePath(relative ? file.filepath : path.resolve(cwd, file.filepath)), |
| 53 | + status: file.status, |
| 54 | + })) |
63 | 55 |
|
64 | 56 | const task = { pattern, commands, fileList } |
65 | 57 | debugLog('Generated task: \n%O', task) |
|
0 commit comments