Skip to content

Commit 4eff3f2

Browse files
Merge pull request #646 from pattern-lab/config-access-for-engines
Config access for pattern engines
2 parents 15c456c + 15f89eb commit 4eff3f2

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

core/lib/pattern_engines.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ function findEngineModulesInDirectory(dir) {
6262

6363
const PatternEngines = Object.create({
6464

65-
loadAllEngines: function () {
65+
loadAllEngines: function (patternLabConfig) {
6666
var self = this;
6767

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

8080
try {
81-
// give it a try! load 'er up. But not if we already have, of course.
81+
// Give it a try! load 'er up. But not if we already have,
82+
// of course. Also pass the pattern lab config object into
83+
// the engine's closure scope so it can know things about
84+
// things.
8285
if (self[engineDiscovery.name]) {
8386
throw new Error("already loaded, skipping.");
8487
}
8588
self[engineDiscovery.name] = require(engineDiscovery.modulePath);
89+
if (typeof self[engineDiscovery.name].usePatternLabConfig === 'function') {
90+
self[engineDiscovery.name].usePatternLabConfig(patternLabConfig);
91+
}
8692
} catch (err) {
8793
errorMessage = err.message;
8894
} finally {

core/lib/patternlab.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ const patternlab_engine = function (config) {
182182
const patternlab = {};
183183

184184
patternlab.engines = patternEngines;
185-
patternlab.engines.loadAllEngines();
185+
patternlab.engines.loadAllEngines(config);
186186

187187
const pattern_assembler = new pa();
188188
const pattern_exporter = new pe();

0 commit comments

Comments
 (0)