1
1
/*
2
- * patternlab-node - v2.4.1 - 2016
2
+ * patternlab-node - v2.4.2 - 2016
3
3
*
4
4
* Brian Muenzenmeyer, Geoff Pursell, and the web community.
5
5
* Licensed under the MIT license.
13
13
var diveSync = require ( 'diveSync' ) ,
14
14
glob = require ( 'glob' ) ,
15
15
_ = 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' ) ;
20
18
21
19
function buildPatternData ( dataFilesPath , fs ) {
22
20
var dataFilesPath = dataFilesPath ;
@@ -29,6 +27,8 @@ function buildPatternData(dataFilesPath, fs) {
29
27
return mergeObject ;
30
28
}
31
29
30
+ // GTP: these two diveSync pattern processors factored out so they can be reused
31
+ // from unit tests to reduce code dupe!
32
32
function processAllPatternsIterative ( pattern_assembler , patterns_dir , patternlab ) {
33
33
diveSync (
34
34
patterns_dir ,
@@ -57,6 +57,23 @@ function processAllPatternsRecursive(pattern_assembler, patterns_dir, patternlab
57
57
) ;
58
58
}
59
59
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
+
60
77
var patternlab_engine = function ( config ) {
61
78
'use strict' ;
62
79
@@ -66,13 +83,14 @@ var patternlab_engine = function (config) {
66
83
pe = require ( './pattern_exporter' ) ,
67
84
lh = require ( './lineage_hunter' ) ,
68
85
ui = require ( './ui_builder' ) ,
69
- plutils = require ( './utilities' ) ,
70
86
sm = require ( './starterkit_manager' ) ,
71
87
patternlab = { } ;
72
88
73
89
patternlab . package = fs . readJSONSync ( path . resolve ( __dirname , '../../package.json' ) ) ;
74
90
patternlab . config = config || fs . readJSONSync ( path . resolve ( __dirname , '../../patternlab-config.json' ) ) ;
75
91
92
+ checkConfiguration ( patternlab ) ;
93
+
76
94
var paths = patternlab . config . paths ;
77
95
78
96
function getVersion ( ) {
@@ -335,23 +353,15 @@ var patternlab_engine = function (config) {
335
353
patternLabFoot : footerPartial
336
354
} ) ;
337
355
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
-
346
356
//write the compiled template to the public patterns directory
347
357
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 ) ;
349
359
350
360
//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 ) ;
352
362
353
363
//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 ) ;
355
365
356
366
return true ;
357
367
} ) ;
0 commit comments