Skip to content
This repository was archived by the owner on Dec 10, 2019. It is now read-only.

Commit 552b93d

Browse files
committed
wip better plugin mgmt
1 parent cd296f3 commit 552b93d

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

index.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,21 @@ function pluginInit(patternlab) {
104104
}
105105
}
106106

107-
//setup listeners if not already active
108-
if (patternlab.config[pluginName] !== undefined && !patternlab.config[pluginName]) {
107+
//setup listeners if not already active. we also enable and set the plugin as initialized
108+
if (!patternlab.config.plugins) {
109+
patternlab.config.plugins = {};
110+
}
111+
112+
//attempt to only register events once
113+
if (patternlab.config.plugins[pluginName] !== undefined &&
114+
patternlab.config.plugins[pluginName].enabled &&
115+
!patternlab.config.plugins[pluginName].initialized) {
109116

110117
//register events
111118
registerEvents(patternlab);
112119

113-
//set the plugin key to true to indicate it is installed and ready
114-
patternlab.config[pluginName] = true;
120+
//set the plugin initialized flag to true to indicate it is installed and ready
121+
patternlab.config.plugins[pluginName].initialized = true;
115122
}
116123

117124
}

0 commit comments

Comments
 (0)