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

Commit c13eec8

Browse files
Merge pull request #14 from pattern-lab/dev
1.0.0
2 parents cd296f3 + 69cdd9e commit c13eec8

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,25 @@ To add the Tab Plugin to your project using [npm](http://npmjs.com/) type:
1616

1717
Or add it directly to your project's `package.json` file and run `npm install`
1818

19-
Post installation, the plugin will prompt you for what filetypes you want to add tabs for.
19+
At time of installation, the plugin will prompt you for what filetypes you want to add tabs for.
2020

2121
```
2222
$ Specify filetype(s) to create a tab for. Separate multiple filetypes with a space, pipe or comma. Example: js css >>>
2323
```
2424

25+
Post-installation, the plugin should be added as a key to the `plugins` object in your main Pattern Lab project's `patternlab-config.json` file.
26+
27+
Example:
28+
29+
```
30+
"plugins": {
31+
"plugin-node-tab": {
32+
"enabled": true,
33+
"initialized": false
34+
}
35+
}
36+
```
37+
2538
## Expected Structure
2639

2740
With the Tab Plugin installed, you can now accompany pattern template files with the file types of your choice and expect Pattern Lab to show them as tabs. The file structure would be similar to that of `pattern.json` or `pattern.md` files, except that it will be `pattern.<<type>>`.
@@ -38,4 +51,4 @@ For example, if we added a` css` tab:
3851

3952
## Enabling / Disabling the Plugin
4053

41-
After install, you may manually enable or disable the plugin by removing it from the `patternlab-config.json` file. Installation added a key called `plugin-node-tab` to it. In the future this will be possible via CLI.
54+
After install, you may manually enable or disable the plugin by finding the `plugin-node-tab` key within your main Pattern Lab project's `patternlab-config.json` file and setting the `enabled` flag. In the future this will be possible via CLI.

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
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "plugin-node-tab",
3-
"version": "1.0.0-alpha",
3+
"version": "1.0.0",
44
"description": "",
55
"main": "index.js",
66
"dependencies": {

0 commit comments

Comments
 (0)