@@ -54,20 +54,6 @@ var ui_builder = function () {
54
54
}
55
55
}
56
56
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
-
71
57
/**
72
58
* Returns whether or not the pattern should be excluded from direct rendering or navigation on the front end
73
59
* @param pattern - the pattern to test for inclusion/exclusion
@@ -468,7 +454,7 @@ var ui_builder = function () {
468
454
//do not create a viewall page for flat patterns
469
455
if ( patternType === patternSubtype ) {
470
456
writeViewAllFile = false ;
471
- return false ;
457
+ return ;
472
458
}
473
459
474
460
//render the footer needed for the viewall template
@@ -485,13 +471,12 @@ var ui_builder = function () {
485
471
typePatterns = typePatterns . concat ( subtypePatterns ) ;
486
472
487
473
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 ) ;
490
475
} ) ;
491
476
492
477
//do not create a viewall page for flat patterns
493
478
if ( ! writeViewAllFile || ! p ) {
494
- return false ;
479
+ return ;
495
480
}
496
481
497
482
//render the footer needed for the viewall template
@@ -507,7 +492,7 @@ var ui_builder = function () {
507
492
508
493
//render the viewall template for the type
509
494
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 ) ;
511
496
512
497
//determine if we should omit this patterntype completely from the viewall page
513
498
var omitPatternType = styleGuideExcludes && styleGuideExcludes . length
@@ -521,8 +506,6 @@ var ui_builder = function () {
521
506
} else {
522
507
patterns = patterns . concat ( typePatterns ) ;
523
508
}
524
-
525
- return true ; //stop yelling at us eslint we know we know
526
509
} ) ;
527
510
return patterns ;
528
511
}
@@ -561,12 +544,12 @@ var ui_builder = function () {
561
544
output += 'var defaultPattern = "' + ( patternlab . config . defaultPattern ? patternlab . config . defaultPattern : 'all' ) + '";' + eol ;
562
545
563
546
//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 ) ;
565
548
566
549
//annotations
567
550
var annotationsJSON = annotation_exporter . gather ( ) ;
568
551
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 ) ;
570
553
}
571
554
572
555
/**
@@ -626,7 +609,7 @@ var ui_builder = function () {
626
609
patternSection : patternlab . patternSection ,
627
610
patternSectionSubtype : patternlab . patternSectionSubType
628
611
} ) ;
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 ) ;
630
613
631
614
//move the index file from its asset location into public root
632
615
var patternlabSiteHtml ;
@@ -637,7 +620,7 @@ var ui_builder = function () {
637
620
console . log ( "\nERROR: Could not load one or more styleguidekit assets from" , paths . source . styleguide , '\n' ) ;
638
621
process . exit ( 1 ) ;
639
622
}
640
- writeFile ( path . resolve ( paths . public . root , 'index.html' ) , patternlabSiteHtml ) ;
623
+ fs . outputFileSync ( path . resolve ( paths . public . root , 'index.html' ) , patternlabSiteHtml ) ;
641
624
642
625
//write out patternlab.data object to be read by the client
643
626
exportData ( patternlab ) ;
@@ -655,6 +638,9 @@ var ui_builder = function () {
655
638
} ,
656
639
resetUIBuilderState : function ( patternlab ) {
657
640
resetUIBuilderState ( patternlab ) ;
641
+ } ,
642
+ buildViewAllPages : function ( mainPageHeadHtml , patternlab , styleguidePatterns ) {
643
+ buildViewAllPages ( mainPageHeadHtml , patternlab , styleguidePatterns ) ;
658
644
}
659
645
} ;
660
646
0 commit comments