@@ -7,7 +7,6 @@ const glob = require('glob');
77const path = require ( 'path' ) ;
88const EOL = require ( 'os' ) . EOL ;
99const tab_loader = require ( './src/tab-loader' ) ;
10- const config = require ( './config.json' ) ;
1110
1211function writeConfigToOutput ( patternlab , pluginConfig ) {
1312 var pluginConfigPathName = path . resolve ( patternlab . config . paths . public . root , 'patternlab-components' , 'packages' ) ;
@@ -46,7 +45,7 @@ function getPluginFrontendConfig() {
4645 'javascripts' :[ 'patternlab-components\/pattern-lab\/' + pluginName + '\/js\/' + pluginName + '.js' ] ,
4746 'onready' :'PluginTab.init()' ,
4847 'callback' :''
49- }
48+ } ;
5049}
5150
5251/**
@@ -102,12 +101,14 @@ function pluginInit(patternlab) {
102101 //we are also being a bit lazy here, since we only expect one file
103102 let tabJSFileContents = fs . readFileSync ( pluginFiles [ i ] , 'utf8' ) ;
104103 var snippetString = '' ;
105- for ( let j = 0 ; j < pluginConfig . tabsToAdd . length ; j ++ ) {
106- let tabSnippetLocal = tab_frontend_snippet . replace ( / < < t y p e > > / g, pluginConfig . tabsToAdd [ j ] ) . replace ( / < < t y p e U C > > / g, pluginConfig . tabsToAdd [ j ] . toUpperCase ( ) ) ;
107- snippetString += tabSnippetLocal + EOL ;
104+ if ( pluginConfig . tabsToAdd && pluginConfig . tabsToAdd . length > 0 ) {
105+ for ( let j = 0 ; j < pluginConfig . tabsToAdd . length ; j ++ ) {
106+ let tabSnippetLocal = tab_frontend_snippet . replace ( / < < t y p e > > / g, pluginConfig . tabsToAdd [ j ] ) . replace ( / < < t y p e U C > > / g, pluginConfig . tabsToAdd [ j ] . toUpperCase ( ) ) ;
107+ snippetString += tabSnippetLocal + EOL ;
108+ }
109+ tabJSFileContents = tabJSFileContents . replace ( '/*SNIPPETS*/' , snippetString ) ;
110+ fs . outputFileSync ( writePath , tabJSFileContents ) ;
108111 }
109- tabJSFileContents = tabJSFileContents . replace ( '/*SNIPPETS*/' , snippetString ) ;
110- fs . outputFileSync ( writePath , tabJSFileContents ) ;
111112 }
112113 } catch ( ex ) {
113114 console . trace ( 'plugin-node-tab: Error occurred while copying pluginFile' , pluginFiles [ i ] ) ;
0 commit comments