While trying to switch Docusaurus to Tinyglobby, our CI reported failures: facebook/docusaurus#11042
It turns out there's a behavior that Tinyglobby has that is slightly different from the original Globby:
const Globby = require("globby");
await Globby(
'/Users/sebastienlorber/Desktop/projects/docusaurus/packages/docusaurus-theme-classic/src/theme/Tabs/**/*',
{
cwd: "/Users/sebastienlorber/Desktop/projects/docusaurus/website",
ignore: [
'**/__tests__/*',
],
},
);
const Tinyglobby = require("tinyglobby").glob;
await Tinyglobby(
'/Users/sebastienlorber/Desktop/projects/docusaurus/packages/docusaurus-theme-classic/src/theme/Tabs/**/*',
{
cwd: "/Users/sebastienlorber/Desktop/projects/docusaurus/website",
ignore: [
'**/__tests__/*',
],
},
);
await Tinyglobby(
'/Users/sebastienlorber/Desktop/projects/docusaurus/packages/docusaurus-theme-classic/src/theme/Tabs/**/*',
{
cwd: "/Users/sebastienlorber/Desktop/projects/docusaurus/website",
absolute: true,
ignore: [
'**/__tests__/*',
],
},
);
The Node 24 repl output is:
[
'/Users/sebastienlorber/Desktop/projects/docusaurus/packages/docusaurus-theme-classic/src/theme/Tabs/index.tsx',
'/Users/sebastienlorber/Desktop/projects/docusaurus/packages/docusaurus-theme-classic/src/theme/Tabs/styles.module.css'
]
>
>
>
> const Tinyglobby = require("tinyglobby").glob;
undefined
> await Tinyglobby(
| '/Users/sebastienlorber/Desktop/projects/docusaurus/packages/docusaurus-theme-classic/src/theme/Tabs/**/*',
| {
| cwd: "/Users/sebastienlorber/Desktop/projects/docusaurus/website",
| ignore: [
| '**/__tests__/*',
| ],
| },
| );
[
'../packages/docusaurus-theme-classic/src/theme/Tabs/index.tsx',
'../packages/docusaurus-theme-classic/src/theme/Tabs/styles.module.css',
'../packages/docusaurus-theme-classic/src/theme/Tabs/__tests__/index.test.tsx'
]
>
> await Tinyglobby(
| '/Users/sebastienlorber/Desktop/projects/docusaurus/packages/docusaurus-theme-classic/src/theme/Tabs/**/*',
| {
| cwd: "/Users/sebastienlorber/Desktop/projects/docusaurus/website",
| absolute: true,
| ignore: [
| '**/__tests__/*',
| ],
| },
| );
[
'/Users/sebastienlorber/Desktop/projects/docusaurus/packages/docusaurus-theme-classic/src/theme/Tabs/index.tsx',
'/Users/sebastienlorber/Desktop/projects/docusaurus/packages/docusaurus-theme-classic/src/theme/Tabs/styles.module.css',
'/Users/sebastienlorber/Desktop/projects/docusaurus/packages/docusaurus-theme-classic/src/theme/Tabs/__tests__/index.test.tsx'
]
As you can see, Tinyglobby returns relative paths, and even if we force it to return absolute paths like Globby, it doesn't really ignore the /__tests__/ pattern and returns one extra result that contains that pattern.
If I use cwd: '/Users/sebastienlorber/Desktop/projects/docusaurus' (ie, no ../ in the glob results), then it works as indended.
While trying to switch Docusaurus to Tinyglobby, our CI reported failures: facebook/docusaurus#11042
It turns out there's a behavior that Tinyglobby has that is slightly different from the original Globby:
The Node 24 repl output is:
As you can see, Tinyglobby returns relative paths, and even if we force it to return absolute paths like Globby, it doesn't really ignore the
/__tests__/pattern and returns one extra result that contains that pattern.If I use
cwd: '/Users/sebastienlorber/Desktop/projects/docusaurus'(ie, no../in the glob results), then it works as indended.