Skip to content

Commit 6b2ec81

Browse files
Merge pull request #1077 from pattern-lab/plugin-fixes
Plugin fixes
2 parents d060200 + 0d500ef commit 6b2ec81

File tree

5 files changed

+24
-15
lines changed

5 files changed

+24
-15
lines changed

packages/core/src/lib/plugin_manager.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
const plugin_manager = function() {
44
const path = require('path');
5-
const findModules = require('./findModules');
65
const logger = require('./log');
76

87
const pluginMatcher = /^plugin-(.*)$/;
@@ -38,25 +37,25 @@ const plugin_manager = function() {
3837
* @param {object} patternlab
3938
*/
4039
function initializePlugins(patternlab) {
41-
const nodeModulesPath = path.join(process.cwd(), 'node_modules');
42-
const foundPlugins = findModules(nodeModulesPath, isPlugin);
40+
const foundPlugins = Object.keys(patternlab.config.plugins || {});
4341
foundPlugins.forEach(plugin => {
44-
logger.info(`Found plugin: plugin-${plugin.name}`);
42+
logger.info(`Found plugin: ${plugin}`);
4543
logger.info(`Attempting to load and initialize plugin.`);
46-
const pluginModule = loadPlugin(plugin.modulePath);
44+
const pluginModule = loadPlugin(
45+
path.join(process.cwd(), 'node_modules', plugin)
46+
);
4747
pluginModule(patternlab);
4848
});
4949
}
5050

51-
async function raiseEvent(patternlab, eventName, ...args) {
51+
async function raiseEvent(patternlab, eventName, args) {
5252
patternlab.events.emit(eventName, args);
53-
5453
await (async function() {
5554
const hookHandlers = (patternlab.hooks[eventName] || []).map(h =>
5655
h(args)
5756
);
5857

59-
const results = await Promise.all(hookHandlers);
58+
await Promise.all(hookHandlers);
6059
})();
6160
}
6261

packages/plugin-tab/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ function writeConfigToOutput(patternlab, pluginConfig) {
3636
}
3737
}
3838

39-
async function onPatternIterate(patternlab, pattern) {
39+
async function onPatternIterate(params) {
40+
const [patternlab, pattern] = params;
4041
await tab_loader(patternlab, pattern);
4142
}
4243

packages/uikit-workshop/dist/styleguide/js/patternlab-viewer.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/uikit-workshop/dist/styleguide/js/pl-modal-viewer-chunk-7506fe4aa4d15996d2ad.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/uikit-workshop/src/scripts/components/panels-viewer.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,19 +106,27 @@ export const panelsViewer = {
106106
const e = new XMLHttpRequest();
107107
// @todo: look deeper into how we can refactor this particular code block
108108
/* eslint-disable */
109-
e.onload = (function(i, panels, patternData, iframeRequest) {
110-
return function() {
109+
e.onload = (function (i, panels, patternData, iframeRequest) {
110+
return function () {
111+
112+
// since non-existant files (such as .scss from plugin-tab) still return a 200, we need to instead inspect the contents
113+
// we look for responseText that starts with the doctype
114+
let rText = this.responseText
115+
if (rText.startsWith('<!DOCTYPE html>')) {
116+
rText = ''
117+
}
118+
111119
// use pretty to format HTML
112120
if (panels[i].name === 'HTML') {
113-
templateFormatted = pretty(this.responseText, { ocd: true });
121+
templateFormatted = pretty(rText, { ocd: true });
114122
} else {
115-
templateFormatted = this.responseText;
123+
templateFormatted = rText;
116124
}
117125

118126
const templateHighlighted = Prism.highlight(
119127
templateFormatted,
120128
Prism.languages[panels[i].name.toLowerCase()] ||
121-
Prism.languages['markup']
129+
Prism.languages['markup']
122130
// Prism.languages[panels[i].name.toLowerCase()],
123131
);
124132

0 commit comments

Comments
 (0)