From b62ac2280e1b8b1dd4bb8a2376bf22720fb27b77 Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Mon, 17 Feb 2025 22:45:47 -0800 Subject: [PATCH] chore: use `tinyglobby` instead of `fast-glob` in Vitest (#7504) --- packages/vitest/LICENSE.md | 324 ++---------------- packages/vitest/package.json | 2 +- packages/vitest/rollup.config.js | 5 +- packages/vitest/src/node/project.ts | 7 +- .../src/node/workspace/fast-glob-pattern.ts | 77 ----- .../src/node/workspace/resolveWorkspace.ts | 11 +- pnpm-lock.yaml | 6 +- test/cli/test/__snapshots__/list.test.ts.snap | 40 +-- 8 files changed, 55 insertions(+), 417 deletions(-) delete mode 100644 packages/vitest/src/node/workspace/fast-glob-pattern.ts diff --git a/packages/vitest/LICENSE.md b/packages/vitest/LICENSE.md index 670f2d261ffc..5c433bf5a9b7 100644 --- a/packages/vitest/LICENSE.md +++ b/packages/vitest/LICENSE.md @@ -57,90 +57,6 @@ Repository: git+/~https://github.com/antfu/install-pkg.git --------------------------------------- -## @nodelib/fs.scandir -License: MIT -Repository: /~https://github.com/nodelib/nodelib/tree/master/packages/fs/fs.scandir - -> The MIT License (MIT) -> -> Copyright (c) Denis Malinochkin -> -> Permission is hereby granted, free of charge, to any person obtaining a copy -> of this software and associated documentation files (the "Software"), to deal -> in the Software without restriction, including without limitation the rights -> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -> copies of the Software, and to permit persons to whom the Software is -> furnished to do so, subject to the following conditions: -> -> The above copyright notice and this permission notice shall be included in all -> copies or substantial portions of the Software. -> -> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -> SOFTWARE. - ---------------------------------------- - -## @nodelib/fs.stat -License: MIT -Repository: /~https://github.com/nodelib/nodelib/tree/master/packages/fs/fs.stat - -> The MIT License (MIT) -> -> Copyright (c) Denis Malinochkin -> -> Permission is hereby granted, free of charge, to any person obtaining a copy -> of this software and associated documentation files (the "Software"), to deal -> in the Software without restriction, including without limitation the rights -> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -> copies of the Software, and to permit persons to whom the Software is -> furnished to do so, subject to the following conditions: -> -> The above copyright notice and this permission notice shall be included in all -> copies or substantial portions of the Software. -> -> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -> SOFTWARE. - ---------------------------------------- - -## @nodelib/fs.walk -License: MIT -Repository: /~https://github.com/nodelib/nodelib/tree/master/packages/fs/fs.walk - -> The MIT License (MIT) -> -> Copyright (c) Denis Malinochkin -> -> Permission is hereby granted, free of charge, to any person obtaining a copy -> of this software and associated documentation files (the "Software"), to deal -> in the Software without restriction, including without limitation the rights -> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -> copies of the Software, and to permit persons to whom the Software is -> furnished to do so, subject to the following conditions: -> -> The above copyright notice and this permission notice shall be included in all -> copies or substantial portions of the Software. -> -> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -> SOFTWARE. - ---------------------------------------- - ## @sinonjs/commons License: BSD-3-Clause Repository: git+/~https://github.com/sinonjs/commons.git @@ -341,53 +257,18 @@ Repository: /~https://github.com/debitoor/chai-subset.git --------------------------------------- -## fast-glob +## fdir License: MIT -By: Denis Malinochkin -Repository: mrmlnc/fast-glob +By: thecodrr +Repository: git+/~https://github.com/thecodrr/fdir.git -> The MIT License (MIT) -> -> Copyright (c) Denis Malinochkin -> -> Permission is hereby granted, free of charge, to any person obtaining a copy -> of this software and associated documentation files (the "Software"), to deal -> in the Software without restriction, including without limitation the rights -> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -> copies of the Software, and to permit persons to whom the Software is -> furnished to do so, subject to the following conditions: -> -> The above copyright notice and this permission notice shall be included in all -> copies or substantial portions of the Software. +> Copyright 2023 Abdullah Atta > -> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -> SOFTWARE. - ---------------------------------------- - -## fastq -License: ISC -By: Matteo Collina -Repository: git+/~https://github.com/mcollina/fastq.git - -> Copyright (c) 2015-2020, Matteo Collina +> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: > -> Permission to use, copy, modify, and/or distribute this software for any -> purpose with or without fee is hereby granted, provided that the above -> copyright notice and this permission notice appear in all copies. +> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. > -> THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -> WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -> MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -> ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -> WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -> ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -> OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --------------------------------------- @@ -489,87 +370,6 @@ Repository: privatenumber/get-tsconfig --------------------------------------- -## glob-parent -License: ISC -By: Gulp Team, Elan Shanker, Blaine Bublitz -Repository: gulpjs/glob-parent - -> The ISC License -> -> Copyright (c) 2015, 2019 Elan Shanker -> -> Permission to use, copy, modify, and/or distribute this software for any -> purpose with or without fee is hereby granted, provided that the above -> copyright notice and this permission notice appear in all copies. -> -> THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -> WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -> MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -> ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -> WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -> ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR -> IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ---------------------------------------- - -## is-extglob -License: MIT -By: Jon Schlinkert -Repository: jonschlinkert/is-extglob - -> The MIT License (MIT) -> -> Copyright (c) 2014-2016, Jon Schlinkert -> -> Permission is hereby granted, free of charge, to any person obtaining a copy -> of this software and associated documentation files (the "Software"), to deal -> in the Software without restriction, including without limitation the rights -> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -> copies of the Software, and to permit persons to whom the Software is -> furnished to do so, subject to the following conditions: -> -> The above copyright notice and this permission notice shall be included in -> all copies or substantial portions of the Software. -> -> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -> THE SOFTWARE. - ---------------------------------------- - -## is-glob -License: MIT -By: Jon Schlinkert, Brian Woodward, Daniel Perez -Repository: micromatch/is-glob - -> The MIT License (MIT) -> -> Copyright (c) 2014-2017, Jon Schlinkert. -> -> Permission is hereby granted, free of charge, to any person obtaining a copy -> of this software and associated documentation files (the "Software"), to deal -> in the Software without restriction, including without limitation the rights -> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -> copies of the Software, and to permit persons to whom the Software is -> furnished to do so, subject to the following conditions: -> -> The above copyright notice and this permission notice shall be included in -> all copies or substantial portions of the Software. -> -> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -> THE SOFTWARE. - ---------------------------------------- - ## is-number License: MIT By: Jon Schlinkert, Olsten Larck, Rouven Weßling @@ -703,34 +503,6 @@ Repository: sindresorhus/locate-path --------------------------------------- -## merge2 -License: MIT -Repository: git@github.com:teambition/merge2.git - -> The MIT License (MIT) -> -> Copyright (c) 2014-2020 Teambition -> -> Permission is hereby granted, free of charge, to any person obtaining a copy -> of this software and associated documentation files (the "Software"), to deal -> in the Software without restriction, including without limitation the rights -> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -> copies of the Software, and to permit persons to whom the Software is -> furnished to do so, subject to the following conditions: -> -> The above copyright notice and this permission notice shall be included in all -> copies or substantial portions of the Software. -> -> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -> SOFTWARE. - ---------------------------------------- - ## micromatch License: MIT 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 @@ -909,34 +681,6 @@ Repository: terkelg/prompts --------------------------------------- -## queue-microtask -License: MIT -By: Feross Aboukhadijeh -Repository: git://github.com/feross/queue-microtask.git - -> The MIT License (MIT) -> -> Copyright (c) Feross Aboukhadijeh -> -> Permission is hereby granted, free of charge, to any person obtaining a copy of -> this software and associated documentation files (the "Software"), to deal in -> the Software without restriction, including without limitation the rights to -> use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -> the Software, and to permit persons to whom the Software is furnished to do so, -> subject to the following conditions: -> -> The above copyright notice and this permission notice shall be included in all -> copies or substantial portions of the Software. -> -> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -> FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -> COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -> IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -> CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - ---------------------------------------- - ## resolve-pkg-maps License: MIT By: Hiroki Osame @@ -966,14 +710,14 @@ Repository: privatenumber/resolve-pkg-maps --------------------------------------- -## reusify +## sisteransi License: MIT -By: Matteo Collina -Repository: git+/~https://github.com/mcollina/reusify.git +By: Terkel Gjervig +Repository: /~https://github.com/terkelg/sisteransi -> The MIT License (MIT) +> MIT License > -> Copyright (c) 2015 Matteo Collina +> Copyright (c) 2018 Terkel Gjervig Nielsen > > Permission is hereby granted, free of charge, to any person obtaining a copy > of this software and associated documentation files (the "Software"), to deal @@ -995,42 +739,14 @@ Repository: git+/~https://github.com/mcollina/reusify.git --------------------------------------- -## run-parallel -License: MIT -By: Feross Aboukhadijeh -Repository: git://github.com/feross/run-parallel.git - -> The MIT License (MIT) -> -> Copyright (c) Feross Aboukhadijeh -> -> Permission is hereby granted, free of charge, to any person obtaining a copy of -> this software and associated documentation files (the "Software"), to deal in -> the Software without restriction, including without limitation the rights to -> use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -> the Software, and to permit persons to whom the Software is furnished to do so, -> subject to the following conditions: -> -> The above copyright notice and this permission notice shall be included in all -> copies or substantial portions of the Software. -> -> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -> FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -> COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -> IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -> CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - ---------------------------------------- - -## sisteransi +## strip-literal License: MIT -By: Terkel Gjervig -Repository: /~https://github.com/terkelg/sisteransi +By: Anthony Fu +Repository: git+/~https://github.com/antfu/strip-literal.git > MIT License > -> Copyright (c) 2018 Terkel Gjervig Nielsen +> Copyright (c) 2022 Anthony Fu > > Permission is hereby granted, free of charge, to any person obtaining a copy > of this software and associated documentation files (the "Software"), to deal @@ -1052,14 +768,14 @@ Repository: /~https://github.com/terkelg/sisteransi --------------------------------------- -## strip-literal +## tinyglobby License: MIT -By: Anthony Fu -Repository: git+/~https://github.com/antfu/strip-literal.git +By: Superchupu +Repository: git+/~https://github.com/SuperchupuDev/tinyglobby.git > MIT License > -> Copyright (c) 2022 Anthony Fu +> Copyright (c) 2024 Madeline Gurriarán > > Permission is hereby granted, free of charge, to any person obtaining a copy > of this software and associated documentation files (the "Software"), to deal diff --git a/packages/vitest/package.json b/packages/vitest/package.json index ee9c6e92c6d2..181a8221a5e9 100644 --- a/packages/vitest/package.json +++ b/packages/vitest/package.json @@ -193,7 +193,6 @@ "birpc": "0.2.19", "cac": "^6.7.14", "chai-subset": "^1.6.0", - "fast-glob": "3.3.3", "find-up": "^6.3.0", "flatted": "^3.3.2", "get-tsconfig": "^4.10.0", @@ -204,6 +203,7 @@ "pretty-format": "^29.7.0", "prompts": "^2.4.2", "strip-literal": "^2.1.1", + "tinyglobby": "^0.2.10", "ws": "^8.18.0" } } diff --git a/packages/vitest/rollup.config.js b/packages/vitest/rollup.config.js index 7c69269134f8..35c2175fdef2 100644 --- a/packages/vitest/rollup.config.js +++ b/packages/vitest/rollup.config.js @@ -4,12 +4,12 @@ import { fileURLToPath } from 'node:url' import commonjs from '@rollup/plugin-commonjs' import json from '@rollup/plugin-json' import nodeResolve from '@rollup/plugin-node-resolve' -import fg from 'fast-glob' import { dirname, join, normalize, resolve } from 'pathe' import { defineConfig } from 'rollup' import dts from 'rollup-plugin-dts' import esbuild from 'rollup-plugin-esbuild' import license from 'rollup-plugin-license' +import { globSync } from 'tinyglobby' import c from 'tinyrainbow' const require = createRequire(import.meta.url) @@ -199,8 +199,9 @@ function licensePlugin() { preserveSymlinks: false, }), ) - const [licenseFile] = fg.sync(`${pkgDir}/LICENSE*`, { + const [licenseFile] = globSync(`${pkgDir}/LICENSE*`, { caseSensitiveMatch: false, + expandDirectories: false, }) if (licenseFile) { licenseText = fs.readFileSync(licenseFile, 'utf-8') diff --git a/packages/vitest/src/node/project.ts b/packages/vitest/src/node/project.ts index 86edf8a92e47..58ea4cdcbcd3 100644 --- a/packages/vitest/src/node/project.ts +++ b/packages/vitest/src/node/project.ts @@ -22,9 +22,9 @@ import { rm } from 'node:fs/promises' import { tmpdir } from 'node:os' import path from 'node:path' import { deepMerge, nanoid, slash } from '@vitest/utils' -import fg from 'fast-glob' import mm from 'micromatch' import { isAbsolute, join, relative } from 'pathe' +import { glob, type GlobOptions } from 'tinyglobby' import { ViteNodeRunner } from 'vite-node/client' import { ViteNodeServer } from 'vite-node/server' import { setup } from '../api/setup' @@ -421,13 +421,14 @@ export class TestProject { /** @internal */ async globFiles(include: string[], exclude: string[], cwd: string) { - const globOptions: fg.Options = { + const globOptions: GlobOptions = { dot: true, cwd, ignore: exclude, + expandDirectories: false, } - const files = await fg(include, globOptions) + const files = await glob(include, globOptions) // keep the slashes consistent with Vite // we are not using the pathe here because it normalizes the drive letter on Windows // and we want to keep it the same as working dir diff --git a/packages/vitest/src/node/workspace/fast-glob-pattern.ts b/packages/vitest/src/node/workspace/fast-glob-pattern.ts deleted file mode 100644 index bf84f736a34c..000000000000 --- a/packages/vitest/src/node/workspace/fast-glob-pattern.ts +++ /dev/null @@ -1,77 +0,0 @@ -type Pattern = string -type PatternTypeOptions = any - -// copy of fast-glob's isDynamicPattern until it's implemented on tinyglobby -// /~https://github.com/SuperchupuDev/tinyglobby/issues/28 -// /~https://github.com/mrmlnc/fast-glob/blob/da648078ae87bce81fcd42e64d5b2b1360c47b09/src/utils/pattern.ts#L35 - -/* -MIT License - -Copyright (c) Denis Malinochkin - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -const ESCAPE_SYMBOL = '\\' - -const COMMON_GLOB_SYMBOLS_RE = /[*?]|^!/ -const REGEX_CHARACTER_CLASS_SYMBOLS_RE = /\[[^[]*\]/ -const REGEX_GROUP_SYMBOLS_RE = /(?:^|[^!*+?@])\([^(]*\|[^|]*\)/ -const GLOB_EXTENSION_SYMBOLS_RE = /[!*+?@]\([^(]*\)/ -const BRACE_EXPANSION_SEPARATORS_RE = /,|\.\./ - -export function isDynamicPattern(pattern: Pattern, options: PatternTypeOptions = {}): boolean { - /** - * A special case with an empty string is necessary for matching patterns that start with a forward slash. - * An empty string cannot be a dynamic pattern. - * For example, the pattern `/lib/*` will be spread into parts: '', 'lib', '*'. - */ - if (pattern === '') { - return false - } - - /** - * When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check - * filepath directly (without read directory). - */ - if (options.caseSensitiveMatch === false || pattern.includes(ESCAPE_SYMBOL)) { - return true - } - - if (COMMON_GLOB_SYMBOLS_RE.test(pattern) || REGEX_CHARACTER_CLASS_SYMBOLS_RE.test(pattern) || REGEX_GROUP_SYMBOLS_RE.test(pattern)) { - return true - } - - if (options.extglob !== false && GLOB_EXTENSION_SYMBOLS_RE.test(pattern)) { - return true - } - - if (options.braceExpansion !== false && hasBraceExpansion(pattern)) { - return true - } - - return false -} - -function hasBraceExpansion(pattern: string): boolean { - const openingBraceIndex = pattern.indexOf('{') - - if (openingBraceIndex === -1) { - return false - } - - const closingBraceIndex = pattern.indexOf('}', openingBraceIndex + 1) - - if (closingBraceIndex === -1) { - return false - } - - const braceContent = pattern.slice(openingBraceIndex, closingBraceIndex) - - return BRACE_EXPANSION_SEPARATORS_RE.test(braceContent) -} diff --git a/packages/vitest/src/node/workspace/resolveWorkspace.ts b/packages/vitest/src/node/workspace/resolveWorkspace.ts index 441a133fc05f..ad48fe193579 100644 --- a/packages/vitest/src/node/workspace/resolveWorkspace.ts +++ b/packages/vitest/src/node/workspace/resolveWorkspace.ts @@ -4,15 +4,14 @@ import { existsSync, promises as fs } from 'node:fs' import os from 'node:os' import { limitConcurrency } from '@vitest/runner/utils' import { deepClone } from '@vitest/utils' -import fg from 'fast-glob' import { dirname, relative, resolve } from 'pathe' +import { glob, type GlobOptions, isDynamicPattern } from 'tinyglobby' import { mergeConfig } from 'vite' import { configFiles as defaultConfigFiles } from '../../constants' import { isTTY } from '../../utils/env' import { VitestFilteredOutProjectError } from '../errors' import { initializeProject, TestProject } from '../project' import { withLabel } from '../reporters/renderers/utils' -import { isDynamicPattern } from './fast-glob-pattern' export async function resolveWorkspace( vitest: Vitest, @@ -397,14 +396,12 @@ async function resolveTestProjectConfigs( } if (workspaceGlobMatches.length) { - const globOptions: fg.Options = { + const globOptions: GlobOptions = { absolute: true, dot: true, onlyFiles: false, cwd: vitest.config.root, - markDirectories: true, - // TODO: revert option when we go back to tinyglobby - // expandDirectories: false, + expandDirectories: false, ignore: [ '**/node_modules/**', // temporary vite config file @@ -414,7 +411,7 @@ async function resolveTestProjectConfigs( ], } - const workspacesFs = await fg.glob(workspaceGlobMatches, globOptions) + const workspacesFs = await glob(workspaceGlobMatches, globOptions) await Promise.all(workspacesFs.map(async (path) => { // directories are allowed with a glob like `packages/*` diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1742b48a0a6c..82db30ae1c81 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -965,9 +965,6 @@ importers: chai-subset: specifier: ^1.6.0 version: 1.6.0 - fast-glob: - specifier: 3.3.3 - version: 3.3.3 find-up: specifier: ^6.3.0 version: 6.3.0 @@ -998,6 +995,9 @@ importers: strip-literal: specifier: ^2.1.1 version: 2.1.1 + tinyglobby: + specifier: ^0.2.10 + version: 0.2.10 ws: specifier: ^8.18.0 version: 8.18.0 diff --git a/test/cli/test/__snapshots__/list.test.ts.snap b/test/cli/test/__snapshots__/list.test.ts.snap index 2dc10a05972d..44ddb5f3b14e 100644 --- a/test/cli/test/__snapshots__/list.test.ts.snap +++ b/test/cli/test/__snapshots__/list.test.ts.snap @@ -1,13 +1,7 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html exports[`basic output shows error 1`] = ` -"Error: top level error - ❯ top-level-error.test.ts:1:7 - 1| throw new Error('top level error') - | ^ - 2| - -Error: describe error +"Error: describe error ❯ describe-error.test.ts:4:9 2| 3| describe('describe error', () => { @@ -16,6 +10,12 @@ Error: describe error 5| 6| it('wont run', () => { +Error: top level error + ❯ top-level-error.test.ts:1:7 + 1| throw new Error('top level error') + | ^ + 2| + " `; @@ -60,13 +60,7 @@ math.test.ts > failing test `; exports[`json output shows error 1`] = ` -"Error: top level error - ❯ top-level-error.test.ts:1:7 - 1| throw new Error('top level error') - | ^ - 2| - -Error: describe error +"Error: describe error ❯ describe-error.test.ts:4:9 2| 3| describe('describe error', () => { @@ -75,17 +69,17 @@ Error: describe error 5| 6| it('wont run', () => { -" -`; - -exports[`json with a file output shows error 1`] = ` -"Error: top level error +Error: top level error ❯ top-level-error.test.ts:1:7 1| throw new Error('top level error') | ^ 2| -Error: describe error +" +`; + +exports[`json with a file output shows error 1`] = ` +"Error: describe error ❯ describe-error.test.ts:4:9 2| 3| describe('describe error', () => { @@ -94,5 +88,11 @@ Error: describe error 5| 6| it('wont run', () => { +Error: top level error + ❯ top-level-error.test.ts:1:7 + 1| throw new Error('top level error') + | ^ + 2| + " `;