@@ -280,11 +280,13 @@ const patternlab_engine = function (config) {
280
280
return value ;
281
281
}
282
282
283
+ // GTP: this commented out now on the advice of Brian, because we think nobody looks at it,
284
+ // and it causes problems.
283
285
//debug file can be written by setting flag on patternlab-config.json
284
- if ( patternlab . config . debug ) {
285
- console . log ( 'writing patternlab debug file to ./patternlab.json' ) ;
286
- fs . outputFileSync ( './patternlab.json' , JSON . stringify ( patternlab , propertyStringReplacer , 3 ) ) ;
287
- }
286
+ // if (patternlab.config.debug) {
287
+ // console.log('writing patternlab debug file to ./patternlab.json');
288
+ // fs.outputFileSync('./patternlab.json', JSON.stringify(patternlab, propertyStringReplacer, 3));
289
+ // }
288
290
}
289
291
290
292
function setCacheBust ( ) {
@@ -382,7 +384,7 @@ const patternlab_engine = function (config) {
382
384
function renderSinglePattern ( pattern , head ) {
383
385
// Pattern does not need to be built and recompiled more than once
384
386
if ( ! pattern . isPattern || pattern . compileState === CompileState . CLEAN ) {
385
- return false ;
387
+ return Promise . resolve ( false ) ;
386
388
}
387
389
388
390
// Allows serializing the compile state
@@ -478,7 +480,8 @@ const patternlab_engine = function (config) {
478
480
// Allows serializing the compile state
479
481
patternlab . graph . node ( pattern ) . compileState = pattern . compileState = CompileState . CLEAN ;
480
482
plutils . log . info ( "Built pattern: " + pattern . patternPartial ) ;
481
- return true ;
483
+
484
+ return Promise . resolve ( true ) ;
482
485
}
483
486
484
487
/**
@@ -630,17 +633,21 @@ const patternlab_engine = function (config) {
630
633
}
631
634
632
635
//render all patterns last, so lineageR works
633
- patternsToBuild . forEach ( pattern => renderSinglePattern ( pattern , head ) ) ;
634
-
635
- // Saves the pattern graph when all files have been compiled
636
- PatternGraph . storeToFile ( patternlab ) ;
637
- if ( patternlab . config . exportToGraphViz ) {
638
- PatternGraph . exportToDot ( patternlab , "dependencyGraph.dot" ) ;
639
- plutils . log . info ( `Exported pattern graph to ${ path . join ( config . paths . public . root , "dependencyGraph.dot" ) } ` ) ;
640
- }
641
-
642
- //export patterns if necessary
643
- pattern_exporter . export_patterns ( patternlab ) ;
636
+ return patternsToBuild
637
+ . reduce ( ( previousPromise , pattern ) => {
638
+ return previousPromise . then ( ( ) => renderSinglePattern ( pattern , head ) ) ;
639
+ } , Promise . resolve ( ) )
640
+ . then ( ( ) => {
641
+ // Saves the pattern graph when all files have been compiled
642
+ PatternGraph . storeToFile ( patternlab ) ;
643
+ if ( patternlab . config . exportToGraphViz ) {
644
+ PatternGraph . exportToDot ( patternlab , "dependencyGraph.dot" ) ;
645
+ plutils . log . info ( `Exported pattern graph to ${ path . join ( config . paths . public . root , "dependencyGraph.dot" ) } ` ) ;
646
+ }
647
+
648
+ //export patterns if necessary
649
+ pattern_exporter . export_patterns ( patternlab ) ;
650
+ } ) ;
644
651
} ) . catch ( ( err ) => {
645
652
console . log ( 'Error in buildPatterns():' , err ) ;
646
653
} ) ;
0 commit comments