-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Globbing doesn't make sense #23
Comments
I see this is closed, but I'm trying to figure out how to use globbing myself. It seems that adding a pattern to |
I guess I need to split my glob pattern into multiple pieces? One piece with the path, and the other with the globby parts of the glob pattern? |
@thecodrr could you explain how
And this command is not finding it: const files = (await new FDir()
.withFullPaths()
.withSymlinks()
.glob('/Users/ianvs/code/storybook/storybook/sandbox/react-vite-default-js/template-stories/**/*.stories.@(js|jsx|ts|tsx|mdx)')
.crawl('/Users/ianvs/code/storybook/storybook/sandbox/react-vite-default-js/template-stories')
.withPromise()) as string[]; And this doesn't work either: const files = (await new FDir()
.withFullPaths()
.withSymlinks()
.glob('**/*.stories.@(js|jsx|ts|tsx|mdx)')
.crawl('/Users/ianvs/code/storybook/storybook/sandbox/react-vite-default-js/template-stories')
.withPromise()) as string[]; In fact that second option finds all kinds of files outside of the directory specified by I think I must be missing something... |
I tested the code samples you gave and it is working without an issue. I created the same directory structure using: mkdir -p react-vite-default-js/template-stories/addons/docs/docs2/
touch react-vite-default-js/template-stories/addons/docs/docs2/button.stories.{ts,tsx,js,jsx,mdx}
touch react-vite-default-js/button.stories.{ts,tsx,js,jsx,mdx} The directory structure now looks like this:
Running the first sample: const files = await new fdir()
.withFullPaths()
.withSymlinks()
.glob(
"/home/thecodrr/Sources/Repos/fdir/react-vite-default-js/template-stories/**/*.stories.@(js|jsx|ts|tsx|mdx)"
)
.crawl(
"/home/thecodrr/Sources/Repos/fdir/react-vite-default-js/template-stories"
)
.withPromise(); I get: [
'/home/thecodrr/Sources/Repos/fdir/react-vite-default-js/template-stories/addons/docs/docs2/button.stories.js',
'/home/thecodrr/Sources/Repos/fdir/react-vite-default-js/template-stories/addons/docs/docs2/button.stories.jsx',
'/home/thecodrr/Sources/Repos/fdir/react-vite-default-js/template-stories/addons/docs/docs2/button.stories.mdx',
'/home/thecodrr/Sources/Repos/fdir/react-vite-default-js/template-stories/addons/docs/docs2/button.stories.ts',
'/home/thecodrr/Sources/Repos/fdir/react-vite-default-js/template-stories/addons/docs/docs2/button.stories.tsx'
] And the second sample: const files = await new fdir()
.withFullPaths()
.withSymlinks()
.glob("**/*.stories.@(js|jsx|ts|tsx|mdx)")
.crawl(
"/home/thecodrr/Sources/Repos/fdir/react-vite-default-js/template-stories"
)
.withPromise(); I get: [
'/home/thecodrr/Sources/Repos/fdir/react-vite-default-js/template-stories/addons/docs/docs2/button.stories.js',
'/home/thecodrr/Sources/Repos/fdir/react-vite-default-js/template-stories/addons/docs/docs2/button.stories.jsx',
'/home/thecodrr/Sources/Repos/fdir/react-vite-default-js/template-stories/addons/docs/docs2/button.stories.mdx',
'/home/thecodrr/Sources/Repos/fdir/react-vite-default-js/template-stories/addons/docs/docs2/button.stories.ts',
'/home/thecodrr/Sources/Repos/fdir/react-vite-default-js/template-stories/addons/docs/docs2/button.stories.tsx'
] |
Interesting. The only other wrinkle might be the handling of symlinks, then. Are globs resolved based on actual path, or the symlink path? In my case, |
FWIW, I'm seeing this behavior in storybookjs/storybook#19297. It's easy to reproduce if you'd like to clone and checkout the branch, then try running |
Indeed. Testing again with the following directory structure:
The first sample returns nothing which is actually correct since pattern is matched against the resolved file path, not the symlink path. Changing the glob pattern to The second sample works without an issue though since it matches against all files at any depth irrespective of their base path. The output looks like this: [
'/home/thecodrr/Sources/Repos/fdir/code/addons/docs/template/stories/docs2/button.stories.js',
'/home/thecodrr/Sources/Repos/fdir/code/addons/docs/template/stories/docs2/button.stories.jsx',
'/home/thecodrr/Sources/Repos/fdir/code/addons/docs/template/stories/docs2/button.stories.mdx',
'/home/thecodrr/Sources/Repos/fdir/code/addons/docs/template/stories/docs2/button.stories.ts',
'/home/thecodrr/Sources/Repos/fdir/code/addons/docs/template/stories/docs2/button.stories.tsx'
] |
Perhaps I can adding something like |
Currently the API allows a
.glob(...patterns)
method in the Builder alongside thecrawl
one. All the globbing libraries (fast-glob & glob) that I have used do not allow the user to specify the source directory.Maybe
glob
andcrawl
should be at an equal API level.The text was updated successfully, but these errors were encountered: