Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config access for pattern engines #646

Merged
merged 1 commit into from
Apr 5, 2017
Merged
Show file tree
Hide file tree
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
10 changes: 8 additions & 2 deletions core/lib/pattern_engines.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function findEngineModulesInDirectory(dir) {

const PatternEngines = Object.create({

loadAllEngines: function () {
loadAllEngines: function (patternLabConfig) {
var self = this;

// Try to load engines! We scan for engines at each path specified above. This
Expand All @@ -78,11 +78,17 @@ const PatternEngines = Object.create({
const successMessage = chalk.green("good to go");

try {
// give it a try! load 'er up. But not if we already have, of course.
// Give it a try! load 'er up. But not if we already have,
// of course. Also pass the pattern lab config object into
// the engine's closure scope so it can know things about
// things.
if (self[engineDiscovery.name]) {
throw new Error("already loaded, skipping.");
}
self[engineDiscovery.name] = require(engineDiscovery.modulePath);
if (typeof self[engineDiscovery.name].usePatternLabConfig === 'function') {
self[engineDiscovery.name].usePatternLabConfig(patternLabConfig);
}
} catch (err) {
errorMessage = err.message;
} finally {
Expand Down
2 changes: 1 addition & 1 deletion core/lib/patternlab.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ const patternlab_engine = function (config) {
const patternlab = {};

patternlab.engines = patternEngines;
patternlab.engines.loadAllEngines();
patternlab.engines.loadAllEngines(config);

const pattern_assembler = new pa();
const pattern_exporter = new pe();
Expand Down