Skip to content

Commit

Permalink
Update npm package page creation story file check to include multiple…
Browse files Browse the repository at this point in the history
… file locations
  • Loading branch information
i-like-robots committed Jun 19, 2019
1 parent cd27626 commit d8aba87
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion web/src/lib/create-npm-package-pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ module.exports = async (actions, graphql) => {
throw result.errors;
}

function hasStorybookConfig(relPath) {
const locations = ['stories/index.js', 'storybook/index.js', 'storybook/index.jsx'];

return locations.some((location) => {
const filePath = path.join(relPath, location);
return fs.existsSync(filePath);
});
}

result.data.npmPackages.edges.map(({ node }) => {
// Package manifest slug will be /package so remove it
const pagePath = path.dirname(node.fields.slug);
Expand All @@ -41,7 +50,7 @@ module.exports = async (actions, graphql) => {
packageName: node.manifest.name,
packageDescription: node.manifest.description,
// Flag if Storybook demos are available for this package
storybook: fs.existsSync(path.join(relPath, 'stories', 'index.js')),
storybook: hasStorybookConfig(relPath),
// Associate readme and story nodes via slug
packagePath: path.join(pagePath, 'package'),
readmePath: path.join(pagePath, 'readme')
Expand Down

0 comments on commit d8aba87

Please sign in to comment.