Skip to content

Commit 59dc7e3

Browse files
committed
added a warning about too-deep patterns per @gael-boyenval's suggestion
1 parent b32ce02 commit 59dc7e3

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

core/lib/pattern_assembler.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,19 @@ var pattern_assembler = function () {
244244

245245
function processPatternIterative(relPath, patternlab) {
246246

247+
var relativeDepth = relPath.match(/\w(?=\\)|\w(?=\/)/g || []).length;
248+
if (relativeDepth > 2) {
249+
console.log('');
250+
plutils.logOrange('Warning:');
251+
plutils.logOrange('A pattern file: ' + relPath + ' was found greater than 2 levels deep from ' + patternlab.config.paths.source.patterns + '.');
252+
plutils.logOrange('It\'s strongly suggested to not deviate from the following structure under _patterns/');
253+
plutils.logOrange('[patternType]/[patternSubtype]/[patternName].[patternExtension]');
254+
console.log('');
255+
plutils.logOrange('While Pattern Lab may still function, assets may 404 and frontend links may break. Consider yourself warned. ');
256+
plutils.logOrange('Read More: http://patternlab.io/docs/pattern-organization.html');
257+
console.log('');
258+
}
259+
247260
//check if the found file is a top-level markdown file
248261
var fileObject = path.parse(relPath);
249262
if (fileObject.ext === '.md') {

0 commit comments

Comments
 (0)