11/*
2- * patternlab-node - v2.4.1 - 2016
2+ * patternlab-node - v2.4.2 - 2016
33 *
44 * Brian Muenzenmeyer, Geoff Pursell, and the web community.
55 * Licensed under the MIT license.
1313var diveSync = require ( 'diveSync' ) ,
1414 glob = require ( 'glob' ) ,
1515 _ = require ( 'lodash' ) ,
16- path = require ( 'path' ) ;
17-
18- // GTP: these two diveSync pattern processors factored out so they can be reused
19- // from unit tests to reduce code dupe!
16+ path = require ( 'path' ) ,
17+ plutils = require ( './utilities' ) ;
2018
2119function buildPatternData ( dataFilesPath , fs ) {
2220 var dataFilesPath = dataFilesPath ;
@@ -29,6 +27,8 @@ function buildPatternData(dataFilesPath, fs) {
2927 return mergeObject ;
3028}
3129
30+ // GTP: these two diveSync pattern processors factored out so they can be reused
31+ // from unit tests to reduce code dupe!
3232function processAllPatternsIterative ( pattern_assembler , patterns_dir , patternlab ) {
3333 diveSync (
3434 patterns_dir ,
@@ -57,6 +57,23 @@ function processAllPatternsRecursive(pattern_assembler, patterns_dir, patternlab
5757 ) ;
5858}
5959
60+ function checkConfiguration ( patternlab ) {
61+ //default the output suffixes if not present
62+ var outputFileSuffixes = {
63+ rendered : '' ,
64+ rawTemplate : '' ,
65+ markupOnly : '.markup-only'
66+ }
67+
68+ if ( ! patternlab . config . outputFileSuffixes ) {
69+ plutils . logOrange ( 'Configuration Object "outputFileSuffixes" not found, and defaulted to the following:' ) ;
70+ console . log ( outputFileSuffixes ) ;
71+ plutils . logOrange ( 'Since Pattern Lab Core 2.3.0 this configuration option is required. Suggest you add it to your patternlab-config.json file.' ) ;
72+ console . log ( ) ;
73+ }
74+ patternlab . config . outputFileSuffixes = _ . extend ( outputFileSuffixes , patternlab . config . outputFileSuffixes ) ;
75+ }
76+
6077var patternlab_engine = function ( config ) {
6178 'use strict' ;
6279
@@ -66,13 +83,14 @@ var patternlab_engine = function (config) {
6683 pe = require ( './pattern_exporter' ) ,
6784 lh = require ( './lineage_hunter' ) ,
6885 ui = require ( './ui_builder' ) ,
69- plutils = require ( './utilities' ) ,
7086 sm = require ( './starterkit_manager' ) ,
7187 patternlab = { } ;
7288
7389 patternlab . package = fs . readJSONSync ( path . resolve ( __dirname , '../../package.json' ) ) ;
7490 patternlab . config = config || fs . readJSONSync ( path . resolve ( __dirname , '../../patternlab-config.json' ) ) ;
7591
92+ checkConfiguration ( patternlab ) ;
93+
7694 var paths = patternlab . config . paths ;
7795
7896 function getVersion ( ) {
@@ -335,23 +353,15 @@ var patternlab_engine = function (config) {
335353 patternLabFoot : footerPartial
336354 } ) ;
337355
338- //default the output suffixes if not present
339- var outputFileSuffixes = {
340- rendered : '' ,
341- rawTemplate : '' ,
342- markupOnly : '.markup-only'
343- }
344- outputFileSuffixes = _ . extend ( outputFileSuffixes , patternlab . config . outputFileSuffixes ) ;
345-
346356 //write the compiled template to the public patterns directory
347357 var patternPage = headHTML + pattern . patternPartialCode + footerHTML ;
348- fs . outputFileSync ( paths . public . patterns + pattern . patternLink . replace ( '.html' , outputFileSuffixes . rendered + '.html' ) , patternPage ) ;
358+ fs . outputFileSync ( paths . public . patterns + pattern . patternLink . replace ( '.html' , patternlab . config . outputFileSuffixes . rendered + '.html' ) , patternPage ) ;
349359
350360 //write the mustache file too
351- fs . outputFileSync ( paths . public . patterns + pattern . patternLink . replace ( '.html' , outputFileSuffixes . rawTemplate + pattern . fileExtension ) , pattern . template ) ;
361+ fs . outputFileSync ( paths . public . patterns + pattern . patternLink . replace ( '.html' , patternlab . config . outputFileSuffixes . rawTemplate + pattern . fileExtension ) , pattern . template ) ;
352362
353363 //write the encoded version too
354- fs . outputFileSync ( paths . public . patterns + pattern . patternLink . replace ( '.html' , outputFileSuffixes . markupOnly + '.html' ) , pattern . patternPartialCode ) ;
364+ fs . outputFileSync ( paths . public . patterns + pattern . patternLink . replace ( '.html' , patternlab . config . outputFileSuffixes . markupOnly + '.html' ) , pattern . patternPartialCode ) ;
355365
356366 return true ;
357367 } ) ;
0 commit comments