diff --git a/packages/docusaurus-utils/src/globUtils.ts b/packages/docusaurus-utils/src/globUtils.ts index 0f1b14e244..561ea6649f 100644 --- a/packages/docusaurus-utils/src/globUtils.ts +++ b/packages/docusaurus-utils/src/globUtils.ts @@ -10,11 +10,15 @@ import path from 'path'; import Micromatch from 'micromatch'; // Note: Micromatch is used by Globby import {addSuffix} from '@docusaurus/utils-common'; -import Globby from 'tinyglobby'; +import * as Tinyglobby from 'tinyglobby'; import {posixPath} from './pathUtils'; +type GlobOptions = Tinyglobby.GlobOptions; + +// TODO Docusaurus v4 refactor, hide lib behind home-made abstraction +// See https://github.com/facebook/docusaurus/pull/11042 /** A re-export of the globby instance. */ -export {Globby}; +export const Globby = Tinyglobby.glob; /** * The default glob patterns we ignore when sourcing content. @@ -93,7 +97,7 @@ export function createAbsoluteFilePathMatcher( // See https://github.com/facebook/docusaurus/pull/4222#issuecomment-795517329 export async function safeGlobby( patterns: string[], - options?: Globby.GlobOptions, + options?: GlobOptions, ): Promise { // Required for Windows support, as paths using \ should not be used by globby // (also using the windows hard drive prefix like c: is not a good idea) @@ -101,7 +105,7 @@ export async function safeGlobby( posixPath(path.relative(process.cwd(), dirPath)), ); - return Globby.glob(globPaths, options); + return Globby(globPaths, options); } // A bit weird to put this here, but it's used by core + theme-translations diff --git a/packages/docusaurus/src/commands/swizzle/actions.ts b/packages/docusaurus/src/commands/swizzle/actions.ts index 597d4abc90..d5074697ec 100644 --- a/packages/docusaurus/src/commands/swizzle/actions.ts +++ b/packages/docusaurus/src/commands/swizzle/actions.ts @@ -61,7 +61,7 @@ export async function eject({ const globPatternPosix = posixPath(globPattern); - const filesToCopy = await Globby.glob(globPatternPosix, { + const filesToCopy = await Globby(globPatternPosix, { ignore: _.compact([ '**/*.{story,stories,test,tests}.{js,jsx,ts,tsx}', // When ejecting JS components, we want to avoid emitting TS files diff --git a/packages/docusaurus/src/webpack/aliases/index.ts b/packages/docusaurus/src/webpack/aliases/index.ts index 7fc59ee6b2..dbade3a77e 100644 --- a/packages/docusaurus/src/webpack/aliases/index.ts +++ b/packages/docusaurus/src/webpack/aliases/index.ts @@ -51,7 +51,7 @@ export async function createAliasesForTheme( return {}; } - const themeComponentFiles = await Globby.glob(['**/*.{js,jsx,ts,tsx}'], { + const themeComponentFiles = await Globby(['**/*.{js,jsx,ts,tsx}'], { cwd: themePath, }); diff --git a/yarn.lock b/yarn.lock index b40d2606a1..8824d75bd2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8556,7 +8556,7 @@ fb-watchman@^2.0.0: dependencies: bser "2.1.1" -fdir@^6.4.0, fdir@^6.4.3: +fdir@^6.4.3: version "6.4.3" resolved "https://registry.yarnpkg.com/fdir/-/fdir-6.4.3.tgz#011cdacf837eca9b811c89dbb902df714273db72" integrity sha512-PMXmW2y1hDDfTSRc9gaXIuCCRpuoz3Kaz8cUelp3smouvfT632ozg2vrT6lJsHKKOF59YLbOGfAWGUcKEfRMQw==