@@ -54,20 +54,6 @@ var ui_builder = function () {
5454 }
5555 }
5656
57- /**
58- * Writes a file to disk, with an optional callback
59- * @param filePath - the path to write to with filename
60- * @param data - the file contents
61- * @param callback - an optional callback
62- */
63- function writeFile ( filePath , data , callback ) {
64- if ( callback ) {
65- fs . outputFileSync ( filePath , data , callback ) ;
66- } else {
67- fs . outputFileSync ( filePath , data ) ;
68- }
69- }
70-
7157 /**
7258 * Returns whether or not the pattern should be excluded from direct rendering or navigation on the front end
7359 * @param pattern - the pattern to test for inclusion/exclusion
@@ -468,7 +454,7 @@ var ui_builder = function () {
468454 //do not create a viewall page for flat patterns
469455 if ( patternType === patternSubtype ) {
470456 writeViewAllFile = false ;
471- return false ;
457+ return ;
472458 }
473459
474460 //render the footer needed for the viewall template
@@ -485,13 +471,12 @@ var ui_builder = function () {
485471 typePatterns = typePatterns . concat ( subtypePatterns ) ;
486472
487473 var viewAllHTML = buildViewAllHTML ( patternlab , subtypePatterns , patternPartial ) ;
488- writeFile ( paths . public . patterns + p . flatPatternPath + '/index.html' , mainPageHeadHtml + viewAllHTML + footerHTML ) ;
489- return true ; //stop yelling at us eslint we know we know
474+ fs . outputFileSync ( paths . public . patterns + p . flatPatternPath + '/index.html' , mainPageHeadHtml + viewAllHTML + footerHTML ) ;
490475 } ) ;
491476
492477 //do not create a viewall page for flat patterns
493478 if ( ! writeViewAllFile || ! p ) {
494- return false ;
479+ return ;
495480 }
496481
497482 //render the footer needed for the viewall template
@@ -507,7 +492,7 @@ var ui_builder = function () {
507492
508493 //render the viewall template for the type
509494 var viewAllHTML = buildViewAllHTML ( patternlab , typePatterns , patternType ) ;
510- writeFile ( paths . public . patterns + anyPatternOfType . patternType + '/index.html' , mainPageHeadHtml + viewAllHTML + footerHTML ) ;
495+ fs . outputFileSync ( paths . public . patterns + anyPatternOfType . patternType + '/index.html' , mainPageHeadHtml + viewAllHTML + footerHTML ) ;
511496
512497 //determine if we should omit this patterntype completely from the viewall page
513498 var omitPatternType = styleGuideExcludes && styleGuideExcludes . length
@@ -521,8 +506,6 @@ var ui_builder = function () {
521506 } else {
522507 patterns = patterns . concat ( typePatterns ) ;
523508 }
524-
525- return true ; //stop yelling at us eslint we know we know
526509 } ) ;
527510 return patterns ;
528511 }
@@ -561,12 +544,12 @@ var ui_builder = function () {
561544 output += 'var defaultPattern = "' + ( patternlab . config . defaultPattern ? patternlab . config . defaultPattern : 'all' ) + '";' + eol ;
562545
563546 //write all output to patternlab-data
564- writeFile ( path . resolve ( paths . public . data , 'patternlab-data.js' ) , output ) ;
547+ fs . outputFileSync ( path . resolve ( paths . public . data , 'patternlab-data.js' ) , output ) ;
565548
566549 //annotations
567550 var annotationsJSON = annotation_exporter . gather ( ) ;
568551 var annotations = 'var comments = { "comments" : ' + JSON . stringify ( annotationsJSON ) + '};' ;
569- writeFile ( path . resolve ( paths . public . annotations , 'annotations.js' ) , annotations ) ;
552+ fs . outputFileSync ( path . resolve ( paths . public . annotations , 'annotations.js' ) , annotations ) ;
570553 }
571554
572555 /**
@@ -626,7 +609,7 @@ var ui_builder = function () {
626609 patternSection : patternlab . patternSection ,
627610 patternSectionSubtype : patternlab . patternSectionSubType
628611 } ) ;
629- writeFile ( path . resolve ( paths . public . styleguide , 'html/styleguide.html' ) , headerHTML + styleguideHtml + footerHTML ) ;
612+ fs . outputFileSync ( path . resolve ( paths . public . styleguide , 'html/styleguide.html' ) , headerHTML + styleguideHtml + footerHTML ) ;
630613
631614 //move the index file from its asset location into public root
632615 var patternlabSiteHtml ;
@@ -637,7 +620,7 @@ var ui_builder = function () {
637620 console . log ( "\nERROR: Could not load one or more styleguidekit assets from" , paths . source . styleguide , '\n' ) ;
638621 process . exit ( 1 ) ;
639622 }
640- writeFile ( path . resolve ( paths . public . root , 'index.html' ) , patternlabSiteHtml ) ;
623+ fs . outputFileSync ( path . resolve ( paths . public . root , 'index.html' ) , patternlabSiteHtml ) ;
641624
642625 //write out patternlab.data object to be read by the client
643626 exportData ( patternlab ) ;
@@ -655,6 +638,9 @@ var ui_builder = function () {
655638 } ,
656639 resetUIBuilderState : function ( patternlab ) {
657640 resetUIBuilderState ( patternlab ) ;
641+ } ,
642+ buildViewAllPages : function ( mainPageHeadHtml , patternlab , styleguidePatterns ) {
643+ buildViewAllPages ( mainPageHeadHtml , patternlab , styleguidePatterns ) ;
658644 }
659645 } ;
660646
0 commit comments