|
239 | 239 | return;
|
240 | 240 | }
|
241 | 241 |
|
242 |
| - pattern_assembler.process_pattern_iterative(file.substring(2), patternlab); |
| 242 | + pattern_assembler.process_pattern_iterative(path.resolve(file), patternlab); |
243 | 243 | }
|
244 | 244 | );
|
245 | 245 |
|
|
263 | 263 | return;
|
264 | 264 | }
|
265 | 265 |
|
266 |
| - pattern_assembler.process_pattern_recursive(file.substring(2), patternlab); |
| 266 | + pattern_assembler.process_pattern_recursive(path.resolve(file), patternlab); |
267 | 267 | }
|
268 | 268 | );
|
269 | 269 |
|
|
522 | 522 | test.equals(bookendPattern.extendedTemplate.replace(/\s\s+/g, ' ').replace(/\n/g, ' ').trim(), expectedValue.trim());
|
523 | 523 | test.done();
|
524 | 524 | },
|
| 525 | + 'processPatternIterative - ignores files that start with underscore' : function(test){ |
| 526 | + //arrange |
| 527 | + var diveSync = require('diveSync'); |
| 528 | + var fs = require('fs-extra'); |
| 529 | + var pa = require('../builder/pattern_assembler'); |
| 530 | + var pattern_assembler = new pa(); |
| 531 | + var patterns_dir = './test/files/_patterns'; |
| 532 | + var patternlab = {}; |
| 533 | + patternlab.config = fs.readJSONSync('./config.json'); |
| 534 | + patternlab.config.patterns = {source: patterns_dir}; |
| 535 | + patternlab.data = fs.readJSONSync(path.resolve(patternlab.config.paths.source.data, 'data.json')); |
| 536 | + patternlab.listitems = fs.readJSONSync(path.resolve(patternlab.config.paths.source.data, 'listitems.json')); |
| 537 | + patternlab.header = fs.readFileSync(path.resolve(patternlab.config.paths.source.patternlabFiles, 'pattern-header-footer/header.html'), 'utf8'); |
| 538 | + patternlab.footer = fs.readFileSync(path.resolve(patternlab.config.paths.source.patternlabFiles, 'pattern-header-footer/footer.html'), 'utf8'); |
| 539 | + |
| 540 | + patternlab.patterns = []; |
| 541 | + patternlab.data.link = {}; |
| 542 | + patternlab.partials = {}; |
| 543 | + |
| 544 | + //act |
| 545 | + diveSync(patterns_dir, |
| 546 | + { |
| 547 | + filter: function(path, dir){ |
| 548 | + if(dir){ |
| 549 | + var remainingPath = path.replace(patterns_dir, ''); |
| 550 | + var isValidPath = remainingPath.indexOf('/_') === -1; |
| 551 | + return isValidPath; |
| 552 | + } |
| 553 | + return true; |
| 554 | + } |
| 555 | + }, |
| 556 | + function(err, file){ |
| 557 | + //log any errors |
| 558 | + if(err){ |
| 559 | + console.log(err); |
| 560 | + return; |
| 561 | + } |
| 562 | + |
| 563 | + pattern_assembler.process_pattern_iterative(path.resolve(file), patternlab); |
| 564 | + } |
| 565 | + ); |
| 566 | + |
| 567 | + //assert |
| 568 | + var foundIgnoredPattern = false; |
| 569 | + for(var i = 0; i < patternlab.patterns.length; i++){ |
| 570 | + if(patternlab.patterns[i].fileName[0] === '_'){ |
| 571 | + foundIgnoredPattern = true; |
| 572 | + } |
| 573 | + } |
| 574 | + test.equals(foundIgnoredPattern, false); |
| 575 | + test.done(); |
| 576 | + }, |
525 | 577 | 'processPatternIterative - ignores files that are variants' : function(test){
|
526 | 578 | //arrange
|
527 | 579 | var diveSync = require('diveSync');
|
|
532 | 584 | var patternlab = {};
|
533 | 585 | //THIS IS BAD.
|
534 | 586 | patternlab.config = fs.readJSONSync('./config.json');
|
535 |
| - patternlab.config.patterns = {source: patterns_dir}; |
536 |
| - patternlab.data = fs.readJSONSync('./source/_data/data.json'); |
537 |
| - patternlab.listitems = fs.readJSONSync('./source/_data/listitems.json'); |
538 |
| - patternlab.header = fs.readFileSync('./source/_patternlab-files/pattern-header-footer/header.html', 'utf8'); |
539 |
| - patternlab.footer = fs.readFileSync('./source/_patternlab-files/pattern-header-footer/footer.html', 'utf8'); |
| 587 | + patternlab.config.paths.source.patterns = patterns_dir; |
| 588 | + |
| 589 | + patternlab.data = fs.readJSONSync(path.resolve(patternlab.config.paths.source.data, 'data.json')); |
| 590 | + patternlab.listitems = fs.readJSONSync(path.resolve(patternlab.config.paths.source.data, 'listitems.json')); |
| 591 | + patternlab.header = fs.readFileSync(path.resolve(patternlab.config.paths.source.patternlabFiles, 'pattern-header-footer/header.html'), 'utf8'); |
| 592 | + patternlab.footer = fs.readFileSync(path.resolve(patternlab.config.paths.source.patternlabFiles, 'pattern-header-footer/footer.html'), 'utf8'); |
540 | 593 | patternlab.patterns = [];
|
541 | 594 | patternlab.data.link = {};
|
542 | 595 | patternlab.partials = {};
|
|
560 | 613 | return;
|
561 | 614 | }
|
562 | 615 |
|
563 |
| - pattern_assembler.process_pattern_iterative(file.substring(2), patternlab); |
| 616 | + pattern_assembler.process_pattern_iterative(path.resolve(file), patternlab); |
564 | 617 | }
|
565 | 618 | );
|
566 | 619 |
|
|
0 commit comments