Skip to content

Commit

Permalink
added a warning about too-deep patterns per @gael-boyenval's suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
bmuenzenmeyer committed Aug 30, 2016
1 parent b32ce02 commit 59dc7e3
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions core/lib/pattern_assembler.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,19 @@ var pattern_assembler = function () {

function processPatternIterative(relPath, patternlab) {

var relativeDepth = relPath.match(/\w(?=\\)|\w(?=\/)/g || []).length;
if (relativeDepth > 2) {
console.log('');
plutils.logOrange('Warning:');
plutils.logOrange('A pattern file: ' + relPath + ' was found greater than 2 levels deep from ' + patternlab.config.paths.source.patterns + '.');
plutils.logOrange('It\'s strongly suggested to not deviate from the following structure under _patterns/');
plutils.logOrange('[patternType]/[patternSubtype]/[patternName].[patternExtension]');
console.log('');
plutils.logOrange('While Pattern Lab may still function, assets may 404 and frontend links may break. Consider yourself warned. ');
plutils.logOrange('Read More: http://patternlab.io/docs/pattern-organization.html');
console.log('');
}

//check if the found file is a top-level markdown file
var fileObject = path.parse(relPath);
if (fileObject.ext === '.md') {
Expand Down

0 comments on commit 59dc7e3

Please sign in to comment.