-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Normalize stories in optimizeDeps for entries
- Loading branch information
Showing
3 changed files
with
35 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const path = require('path'); | ||
const glob = require('glob-promise'); | ||
const { normalizeStories } = require('@storybook/core-common'); | ||
|
||
/** | ||
* Return an array of stories and their absolute paths. | ||
*/ | ||
module.exports.listStories = async function listStories(options) { | ||
return ( | ||
await Promise.all( | ||
normalizeStories( | ||
await options.presets.apply('stories', [], options), | ||
{ | ||
configDir: options.configDir, | ||
workingDir: options.configDir, | ||
} | ||
).map(({ directory, files }) => { | ||
const pattern = path.join(directory, files); | ||
|
||
return glob( | ||
path.isAbsolute(pattern) | ||
? pattern | ||
: path.join(options.configDir, pattern) | ||
); | ||
}) | ||
) | ||
).reduce((carry, stories) => carry.concat(stories), []); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters