Skip to content

Commit e59928d

Browse files
committed
merged and covered #414
2 parents ba83de7 + b33ae78 commit e59928d

File tree

3 files changed

+45
-20
lines changed

3 files changed

+45
-20
lines changed

core/lib/patternlab.js

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,6 @@ function buildPatternData(dataFilesPath, fs) {
3232
function processAllPatternsIterative(pattern_assembler, patterns_dir, patternlab) {
3333
diveSync(
3434
patterns_dir,
35-
{
36-
filter: function (thisPath, dir) {
37-
if (dir) {
38-
var remainingPath = thisPath.replace(patterns_dir, '');
39-
var isValidPath = remainingPath.indexOf('/_') === -1;
40-
return isValidPath;
41-
}
42-
return true;
43-
}
44-
},
4535
function (err, file) {
4636
//log any errors
4737
if (err) {
@@ -56,16 +46,6 @@ function processAllPatternsIterative(pattern_assembler, patterns_dir, patternlab
5646
function processAllPatternsRecursive(pattern_assembler, patterns_dir, patternlab) {
5747
diveSync(
5848
patterns_dir,
59-
{
60-
filter: function (thisPath, dir) {
61-
if (dir) {
62-
var remainingPath = thisPath.replace(patterns_dir, '');
63-
var isValidPath = remainingPath.indexOf('/_') === -1;
64-
return isValidPath;
65-
}
66-
return true;
67-
}
68-
},
6949
function (err, file) {
7050
//log any errors
7151
if (err) {

core/lib/ui_builder.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,15 @@ var ui_builder = function () {
113113
return true;
114114
}
115115

116+
//this pattern is contained with a directory prefixed with an underscore (a handy way to hide whole directories from the nav
117+
isOmitted = pattern.relPath.charAt(0) === '_' || pattern.relPath.indexOf('/_') > -1;
118+
if (isOmitted) {
119+
if (patternlab.config.debug) {
120+
console.log('Omitting ' + pattern.patternPartial + ' from styleguide patterns its contained within an underscored directory.');
121+
}
122+
return true;
123+
}
124+
116125
//yay, let's include this on the front end
117126
return isOmitted;
118127
}

test/ui_builder_tests.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,42 @@ exports['ui_builder'] = {
6868
test.done();
6969
},
7070

71+
'isPatternExcluded - returns true when pattern within underscored directory - top level': function (test) {
72+
//arrange
73+
var patternlab = createFakePatternLab({});
74+
var pattern = Pattern.createEmpty({
75+
relPath: '_hidden/patternsubtype/foo.mustache',
76+
isPattern: true,
77+
fileName : 'foo.mustache',
78+
patternPartial: 'hidden-foo'
79+
});
80+
81+
//act
82+
var result = ui.isPatternExcluded(pattern, patternlab);
83+
84+
//assert
85+
test.equals(result, true);
86+
test.done();
87+
},
88+
89+
'isPatternExcluded - returns true when pattern within underscored directory - subtype level': function (test) {
90+
//arrange
91+
var patternlab = createFakePatternLab({});
92+
var pattern = Pattern.createEmpty({
93+
relPath: 'shown/_patternsubtype/foo.mustache',
94+
isPattern: true,
95+
fileName : 'foo.mustache',
96+
patternPartial: 'shown-foo'
97+
});
98+
99+
//act
100+
var result = ui.isPatternExcluded(pattern, patternlab);
101+
102+
//assert
103+
test.equals(result, true);
104+
test.done();
105+
},
106+
71107
'groupPatterns - creates pattern groups correctly': function (test) {
72108
//arrange
73109
var patternlab = createFakePatternLab({

0 commit comments

Comments
 (0)