Skip to content

Commit d85d912

Browse files
Ensure that patterns in direcorties greater than 2 levels deep from source are sorted to the next possible parent directory.
This allowes file structures like: 00-atoms/03-controls/00-button - button.pattern - button.md - button.scss - button.js
1 parent 39c0bb2 commit d85d912

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

packages/core/src/lib/object_factory.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const Pattern = function(relPath, data, patternlab) {
3535
this.relPath = path.normalize(relPath); // '00-atoms/00-global/00-colors.mustache'
3636
this.fileName = pathObj.name; // '00-colors'
3737
this.subdir = pathObj.dir; // '00-atoms/00-global'
38+
this.subdir = (this.subdir.match(/\w(?=\\)|\w(?=\/)/g) || []).length > 1 ? this.subdir.split(/\/|\\/, 2).join(path.sep) : this.subdir; // '00-atoms/03-controls/00-button' -> '00-atoms/00-global'
3839
this.fileExtension = pathObj.ext; // '.mustache'
3940

4041
// this is the unique name, subDir + fileName (sans extension)

0 commit comments

Comments
 (0)