Skip to content

Commit 1c10a2d

Browse files
committed
Merge branch 'dev' into ui-rewrite
2 parents 8f9f6c9 + f67126d commit 1c10a2d

8 files changed

+24
-23
lines changed

core/lib/lineage_hunter.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var lineage_hunter = function () {
1313
if (matches !== null) {
1414
matches.forEach(function (match) {
1515
//get the ancestorPattern
16-
var ancestorPattern = pattern_assembler.findPartial(pattern.findPartial(match), patternlab);
16+
var ancestorPattern = pattern_assembler.getPartial(pattern.findPartial(match), patternlab);
1717

1818
if (ancestorPattern && pattern.lineageIndex.indexOf(ancestorPattern.patternPartial) === -1) {
1919
//add it since it didnt exist
@@ -83,7 +83,7 @@ var lineage_hunter = function () {
8383

8484
//find all lineage - patterns being consumed by this one
8585
for (var h = 0; h < pattern.lineageIndex.length; h++) {
86-
var lineagePattern = pattern_assembler.findPartial(pattern.lineageIndex[h], patternlab);
86+
var lineagePattern = pattern_assembler.getPartial(pattern.lineageIndex[h], patternlab);
8787
setPatternState('fromFuture', lineagePattern, pattern);
8888
}
8989
}
@@ -93,7 +93,7 @@ var lineage_hunter = function () {
9393
//find all reverse lineage - that is, patterns consuming this one
9494
for (var j = 0; j < pattern.lineageRIndex.length; j++) {
9595

96-
var lineageRPattern = pattern_assembler.findPartial(pattern.lineageRIndex[j], patternlab);
96+
var lineageRPattern = pattern_assembler.getPartial(pattern.lineageRIndex[j], patternlab);
9797

9898
//only set patternState if pattern.patternState "is less than" the lineageRPattern.patternstate
9999
//or if lineageRPattern.patternstate (the consuming pattern) does not have a state

core/lib/list_item_hunter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ var list_item_hunter = function () {
8282

8383
//get the partial
8484
var partialName = foundPartials[j].match(/([\w\-\.\/~]+)/g)[0];
85-
var partialPattern = pattern_assembler.findPartial(partialName, patternlab);
85+
var partialPattern = pattern_assembler.getPartial(partialName, patternlab);
8686

8787
//create a copy of the partial so as to not pollute it after the get_pattern_by_key call.
8888
var cleanPartialPattern;

core/lib/parameter_hunter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ var parameter_hunter = function () {
240240
pattern.parameteredPartials.forEach(function (pMatch) {
241241
//find the partial's name and retrieve it
242242
var partialName = pMatch.match(/([\w\-\.\/~]+)/g)[0];
243-
var partialPattern = pattern_assembler.findPartial(partialName, patternlab);
243+
var partialPattern = pattern_assembler.getPartial(partialName, patternlab);
244244

245245
//if we retrieved a pattern we should make sure that its extendedTemplate is reset. looks to fix #190
246246
partialPattern.extendedTemplate = partialPattern.template;

core/lib/pattern_assembler.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ var pattern_assembler = function () {
2929
//else look by verbose syntax
3030
for (var i = 0; i < patternlab.patterns.length; i++) {
3131
switch (partialName) {
32+
case patternlab.patterns[i].relPath:
3233
case patternlab.patterns[i].subdir + '/' + patternlab.patterns[i].fileName:
33-
case patternlab.patterns[i].subdir + '/' + patternlab.patterns[i].fileName + '.mustache':
3434
return patternlab.patterns[i];
3535
}
3636
}
@@ -45,7 +45,8 @@ var pattern_assembler = function () {
4545
return patternlab.patterns[i];
4646
}
4747
}
48-
throw 'Could not find pattern with partial ' + partialName;
48+
console.error('Could not find pattern with partial ' + partialName);
49+
return undefined;
4950
}
5051

5152
function buildListItems(container) {
@@ -417,7 +418,7 @@ var pattern_assembler = function () {
417418

418419
if (linkMatches) {
419420
for (var i = 0; i < linkMatches.length; i++) {
420-
expandedLink = patternlab.data.link[linkMatches[i].split('.')[1]];
421+
expandedLink = encodeURI(patternlab.data.link[linkMatches[i].split('.')[1]]);
421422
if (expandedLink) {
422423
expandedLink = expandedLink.replace('\\', '/');
423424
if (patternlab.config.debug) {
@@ -483,7 +484,7 @@ var pattern_assembler = function () {
483484
process_pattern_recursive: function (file, patternlab, additionalData) {
484485
processPatternRecursive(file, patternlab, additionalData);
485486
},
486-
findPartial: function (partial, patternlab) {
487+
getPartial: function (partial, patternlab) {
487488
return getPartial(partial, patternlab);
488489
},
489490
combine_listItems: function (patternlab) {

core/lib/patternlab.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -244,19 +244,17 @@ var patternlab_engine = function (config) {
244244
patternlab.userHead = fs.readFileSync(path.resolve(paths.source.meta, '_00-head.mustache'), 'utf8');
245245
}
246246
catch (ex) {
247-
if (patternlab.config.debug) {
248-
console.log(ex);
249-
console.log('Could not find optional user-defined header, usually found at ./source/_meta/_00-head.mustache. It was likely deleted.');
250-
}
247+
plutils.logRed('\nWARNING: Could not find the user-editable header template, currently configured to be at ' + path.join(config.paths.source.meta, '_00-head.mustache') + '. Your configured path may be incorrect (check paths.source.meta in your config file), the file may have been deleted, or it may have been left in the wrong place during a migration or update.\n');
248+
if (patternlab.config.debug) { console.log(ex); }
249+
process.exit(1);
251250
}
252251
try {
253252
patternlab.userFoot = fs.readFileSync(path.resolve(paths.source.meta, '_01-foot.mustache'), 'utf8');
254253
}
255254
catch (ex) {
256-
if (patternlab.config.debug) {
257-
console.log(ex);
258-
console.log('Could not find optional user-defined footer, usually found at ./source/_meta/_01-foot.mustache. It was likely deleted.');
259-
}
255+
plutils.logRed('\nWARNING: Could not find the user-editable footer template, currently configured to be at ' + path.join(config.paths.source.meta, '_01-foot.mustache') + '. Your configured path may be incorrect (check paths.source.meta in your config file), the file may have been deleted, or it may have been left in the wrong place during a migration or update.\n');
256+
if (patternlab.config.debug) { console.log(ex); }
257+
process.exit(1);
260258
}
261259

262260
//now that all the main patterns are known, look for any links that might be within data and expand them

test/lineage_hunter_tests.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ exports['lineage hunter '] = {
178178
lineage_hunter.cascade_pattern_states(pl);
179179

180180
//assert
181-
var consumerPatternReturned = pattern_assembler.findPartial('test-foo', pl);
181+
var consumerPatternReturned = pattern_assembler.getPartial('test-foo', pl);
182182
test.equals(consumerPatternReturned.patternState, 'inreview');
183183
test.done();
184184
},
@@ -206,7 +206,7 @@ exports['lineage hunter '] = {
206206
lineage_hunter.cascade_pattern_states(pl);
207207

208208
//assert
209-
var consumerPatternReturned = pattern_assembler.findPartial('test-foo', pl);
209+
var consumerPatternReturned = pattern_assembler.getPartial('test-foo', pl);
210210
test.equals(consumerPatternReturned.lineage[0].lineageState, 'inreview');
211211
test.done();
212212
},
@@ -233,7 +233,7 @@ exports['lineage hunter '] = {
233233
lineage_hunter.cascade_pattern_states(pl);
234234

235235
//assert
236-
var consumedPatternReturned = pattern_assembler.findPartial('test-bar', pl);
236+
var consumedPatternReturned = pattern_assembler.getPartial('test-bar', pl);
237237
test.equals(consumedPatternReturned.lineageR[0].lineageState, 'inreview');
238238

239239
test.done();
@@ -261,7 +261,7 @@ exports['lineage hunter '] = {
261261
lineage_hunter.cascade_pattern_states(pl);
262262

263263
//assert
264-
var consumerPatternReturned = pattern_assembler.findPartial('test-foo', pl);
264+
var consumerPatternReturned = pattern_assembler.getPartial('test-foo', pl);
265265
test.equals(consumerPatternReturned.lineage.length, 1);
266266
test.equals(consumerPatternReturned.lineage[0].lineageState, 'inreview');
267267
test.equals(consumerPatternReturned.patternState, 'inreview');

test/parameter_hunter_tests.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//setup current pattern from what we would have during execution
77
function currentPatternClosure() {
88
return {
9+
"relPath": "02-organisms/02-comments/01-sticky-comment.mustache",
910
"fileName": "01-sticky-comment",
1011
"subdir": "02-organisms/02-comments",
1112
"name": "02-organisms-02-comments-01-sticky-comment",
@@ -28,6 +29,7 @@
2829
return {
2930
patterns: [
3031
{
32+
"relPath": "01-molecules/06-components/02-single-comment.mustache",
3133
"fileName": "02-single-comment",
3234
"subdir": "01-molecules/06-components",
3335
"name": "01-molecules-06-components-02-single-comment",

test/pattern_assembler_tests.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@
419419
});
420420

421421
//act
422-
var result = pattern_assembler.findPartial('character-han', patternlab);
422+
var result = pattern_assembler.getPartial('character-han', patternlab);
423423
//assert
424424
test.equals(result, patternlab.patterns[0]);
425425
test.done();
@@ -441,7 +441,7 @@
441441
});
442442

443443
//act
444-
var result = pattern_assembler.findPartial('molecules-primary-nav', patternlab);
444+
var result = pattern_assembler.getPartial('molecules-primary-nav', patternlab);
445445
//assert
446446
test.equals(result, patternlab.patterns[1]);
447447
test.done();

0 commit comments

Comments
 (0)