config.stories does not accept an array of strings as it should
Describe the bug
globby can accept a string or an array of strings as patterns to search for, but the ladle build script assumes that config.stories is a single string and specifying an array of strings leads to a fatal error:
TypeError: Patterns must be a string or an array of strings
This is due to the build script wrapping config.stories in an array, and thus if the user configures an array of strings we end up with an array of a single array of strings, rather than an array of strings.
See line 39 of build.js.
Reproduction
https://stackblitz.com/edit/ladle-gwkvsl?file=package.json
DEBUG=ladle* npm run dev
DEBUG=ladle* npm run build
Environment
- OS: macOS Monterey 12.4
- Version: 2.0.2
What's your naming scheme? Even a single glob is pretty flexible.
In a mono-repo where we'd like to aggregate stories across the project into a single page. Desired config is: stories: ['../src/src/**/*.stories.tsx', './stories/*.stories.tsx', '../../icons/src/*.stories.tsx']
I guess that could make be expressed in a single glob: ../**/*.stories.tsx, but that might capture more than intended.
It seems like a simple fix to enable multiple globs, tho, which would definitely allow this config variable to be more expressive:
const entryData = await getEntryData(await globby(Array.isArray(config.stories) ? config.stories : [config.stories]));
I was planning to submit a PR for this later today.
I was planning to submit a PR for this later today
Please do.