Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions packages/core/src/lib/loadPattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@ let fs = require('fs-extra'); //eslint-disable-line prefer-const
// loads a pattern from disk, creates a Pattern object from it and
// all its associated files, and records it in patternlab.patterns[]
module.exports = function(relPath, patternlab) {
const fileObject = path.parse(relPath);

//extract some information
const filename = fileObject.base;
const ext = fileObject.ext;
const patternsPath = patternlab.config.paths.source.patterns;

// skip non-pattern files
if (!patternEngines.isPatternFile(filename, patternlab)) {
return null;
}

// Determine patterns nested too deep and show a warning
const relativeDepth = (relPath.match(/\w(?=\\)|\w(?=\/)/g) || []).length;
if (relativeDepth > 3) {
logger.warning('');
Expand Down Expand Up @@ -51,18 +64,6 @@ module.exports = function(relPath, patternlab) {
logger.warning('');
}

const fileObject = path.parse(relPath);

//extract some information
const filename = fileObject.base;
const ext = fileObject.ext;
const patternsPath = patternlab.config.paths.source.patterns;

// skip non-pattern files
if (!patternEngines.isPatternFile(filename, patternlab)) {
return null;
}

//make a new Pattern Object
const currentPattern = new Pattern(relPath, null, patternlab);

Expand Down