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

Commit 8992f36

Browse files
committed
guarding against empty configuration
1 parent ed40aaf commit 8992f36

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

index.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,14 @@ function pluginInit(patternlab) {
102102
//we are also being a bit lazy here, since we only expect one file
103103
let tabJSFileContents = fs.readFileSync(pluginFiles[i], 'utf8');
104104
var snippetString = '';
105-
for (let j = 0; j < pluginConfig.tabsToAdd.length; j++) {
106-
let tabSnippetLocal = tab_frontend_snippet.replace(/<<type>>/g, pluginConfig.tabsToAdd[j]).replace(/<<typeUC>>/g, pluginConfig.tabsToAdd[j].toUpperCase());
107-
snippetString += tabSnippetLocal + EOL;
105+
if (pluginConfig.tabsToAdd && pluginConfig.tabsToAdd.length > 0) {
106+
for (let j = 0; j < pluginConfig.tabsToAdd.length; j++) {
107+
let tabSnippetLocal = tab_frontend_snippet.replace(/<<type>>/g, pluginConfig.tabsToAdd[j]).replace(/<<typeUC>>/g, pluginConfig.tabsToAdd[j].toUpperCase());
108+
snippetString += tabSnippetLocal + EOL;
109+
}
110+
tabJSFileContents = tabJSFileContents.replace('/*SNIPPETS*/', snippetString);
111+
fs.outputFileSync(writePath, tabJSFileContents);
108112
}
109-
tabJSFileContents = tabJSFileContents.replace('/*SNIPPETS*/', snippetString);
110-
fs.outputFileSync(writePath, tabJSFileContents);
111113
}
112114
} catch (ex) {
113115
console.trace('plugin-node-tab: Error occurred while copying pluginFile', pluginFiles[i]);

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": "2.0.0",
3+
"version": "2.0.1",
44
"description": "",
55
"main": "index.js",
66
"dependencies": {

0 commit comments

Comments
 (0)