File tree Expand file tree Collapse file tree 3 files changed +15
-10
lines changed Expand file tree Collapse file tree 3 files changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ async function storybook(serve, options) {
3030 . then ( async function ( response ) {
3131 let stories = { }
3232 for ( const [ storyId , storyInfo ] of Object . entries ( response . data . stories ) ) {
33- if ( ! skipStory ( storyInfo . name , storybookConfig ) ) {
33+ if ( ! skipStory ( storyInfo , storybookConfig ) ) {
3434 stories [ storyId ] = {
3535 name : storyInfo . name ,
3636 kind : storyInfo . kind ,
Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ function filterStories(dirPath, storybookConfig) {
5858 stories = JSON . parse ( fs . readFileSync ( `${ dirPath } /stories.json` ) ) . stories ;
5959
6060 for ( const [ storyId , storyInfo ] of Object . entries ( stories ) ) {
61- if ( ! skipStory ( storyInfo . name , storybookConfig ) ) {
61+ if ( ! skipStory ( storyInfo , storybookConfig ) ) {
6262 storyIds . push ( storyId ) ;
6363 }
6464 }
Original file line number Diff line number Diff line change 11// Returns true or false if the story should be skipped based on include and exclude config
2- function skipStory ( name , config ) {
2+ function skipStory ( story , config ) {
3+ // skip story if it's docs
4+ if ( story . parameters && story . parameters . docsOnly ) {
5+ return true ;
6+ }
7+
38 let matches = regexp => {
4- if ( typeof regexp === 'string' ) {
5- let [ , parsed , flags ] = / ^ \/ ( .+ ) \/ ( \w + ) ? $ / . exec ( regexp ) || [ ] ;
6- regexp = new RegExp ( parsed ?? regexp , flags ) ;
7- }
9+ if ( typeof regexp === 'string' ) {
10+ let [ , parsed , flags ] = / ^ \/ ( .+ ) \/ ( \w + ) ? $ / . exec ( regexp ) || [ ] ;
11+ regexp = new RegExp ( parsed ?? regexp , flags ) ;
12+ }
813
9- return regexp ?. test ?. ( name ) ;
14+ return regexp ?. test ?. ( story . name ) ;
1015 } ;
1116
1217 let include = [ ] . concat ( config ?. include ) . filter ( Boolean ) ;
@@ -15,6 +20,6 @@ function skipStory(name, config) {
1520 let skip = include ?. length ? ! include . some ( matches ) : false ;
1621 if ( ! skip && ! exclude ?. some ( matches ) ) return false ;
1722 return true ;
18- } ;
23+ } ;
1924
20- module . exports = { skipStory } ;
25+ module . exports = { skipStory } ;
You can’t perform that action at this time.
0 commit comments