|
1 |
| -/* |
2 |
| - * patternlab-node - v0.14.0 - 2015 |
3 |
| - * |
| 1 | +/* |
| 2 | + * patternlab-node - v0.14.0 - 2015 |
| 3 | + * |
4 | 4 | * Brian Muenzenmeyer, and the web community.
|
5 | 5 | * Licensed under the MIT license.
|
6 | 6 | *
|
|
92 | 92 | }
|
93 | 93 | }
|
94 | 94 |
|
95 |
| - function isPatternFile(filename, patternlab) { |
| 95 | + // ignore _underscored patterns, dotfiles, and anything not recognized by |
| 96 | + // a loaded pattern engine |
| 97 | + function isPatternFile(filename) { |
| 98 | + // skip hidden patterns/files without a second thought |
| 99 | + if (filename.charAt(0) === '_' || filename.charAt(0) === '.') { |
| 100 | + return false; |
| 101 | + } |
| 102 | + |
| 103 | + // not a hidden pattern, let's dig deeper |
96 | 104 | var engineNames = Object.keys(patternEngines);
|
97 | 105 | var supportedPatternFileExtensions = engineNames.map(function (engineName) {
|
98 | 106 | return patternEngines[engineName].fileExtension;
|
99 | 107 | });
|
100 | 108 | var extension = path.extname(filename);
|
101 |
| - return (supportedPatternFileExtensions.lastIndexOf(extension) != -1); |
| 109 | + return (supportedPatternFileExtensions.lastIndexOf(extension) !== -1); |
102 | 110 | }
|
103 | 111 |
|
104 | 112 | function processPatternIterative(file, patternlab){
|
105 |
| - var fs = require('fs-extra'), |
106 |
| - of = require('./object_factory'), |
107 |
| - path = require('path'); |
108 |
| - |
109 | 113 | //extract some information
|
110 | 114 | var subdir = path.dirname(path.relative(patternlab.config.patterns.source, file)).replace('\\', '/');
|
111 | 115 | var filename = path.basename(file);
|
112 | 116 | var ext = path.extname(filename);
|
113 | 117 |
|
114 |
| - // ignore _underscored patterns, dotfiles, and anything not recognized by |
115 |
| - // a loaded pattern engine |
116 |
| - if (filename.charAt(0) === '_' || |
117 |
| - filename.charAt(0) === '.' || |
118 |
| - (ext === '.json' && filename.indexOf('~') === -1) || |
119 |
| - !isPatternFile(filename, patternlab)) { |
120 |
| - return; |
121 |
| - } |
| 118 | + // skip non-pattern files |
| 119 | + if (!isPatternFile(filename, patternlab)) { return; } |
122 | 120 | console.log('found pattern', file);
|
123 | 121 |
|
124 | 122 | //make a new Pattern Object
|
|
183 | 181 | ph = require('./parameter_hunter'),
|
184 | 182 | pph = require('./pseudopattern_hunter'),
|
185 | 183 | lih = require('./list_item_hunter'),
|
186 |
| - smh = require('./style_modifier_hunter'), |
187 |
| - path = require('path'); |
| 184 | + smh = require('./style_modifier_hunter'); |
188 | 185 |
|
189 | 186 | var parameter_hunter = new ph(),
|
190 | 187 | lineage_hunter = new lh(),
|
|
385 | 382 | },
|
386 | 383 | is_object_empty: function(obj){
|
387 | 384 | return isObjectEmpty(obj);
|
388 |
| - } |
| 385 | + }, |
| 386 | + is_pattern_file: isPatternFile |
389 | 387 | };
|
390 | 388 |
|
391 | 389 | };
|
|
0 commit comments