1
1
"use strict" ;
2
2
3
- const fs = require ( 'fs-extra' ) ,
4
- path = require ( 'path' ) ,
5
- fileTypes = require ( './../package.json' ) . fileTypes ;
3
+ const fs = require ( 'fs-extra' ) ;
4
+ const path = require ( 'path' ) ;
6
5
7
6
/**
8
7
* The backend method that is called during the patternlab-pattern-write-end event.
@@ -12,6 +11,9 @@ const fs = require('fs-extra'),
12
11
*/
13
12
function findTab ( patternlab , pattern ) {
14
13
14
+ //read the filetypes from the configuration
15
+ const fileTypes = patternlab . config . plugins [ 'plugin-node-tab' ] . options . tabsToAdd ;
16
+
15
17
//exit if either of these two parameters are missing
16
18
if ( ! patternlab ) {
17
19
console . error ( 'plugin-node-tab: patternlab object not provided to findTab' ) ;
@@ -28,9 +30,10 @@ function findTab(patternlab, pattern) {
28
30
29
31
//loop through all configured types
30
32
for ( let i = 0 ; i < fileTypes . length ; i ++ ) {
33
+ const fileType = fileTypes [ i ] . toLowerCase ( ) ;
31
34
32
- customFileTypePath = customFileTypePath . substr ( 0 , customFileTypePath . lastIndexOf ( "." ) ) + '.' + fileTypes [ i ] ;
33
- var customFileTypeOutputPath = patternlab . config . paths . public . patterns + pattern . getPatternLink ( patternlab , 'custom' , '.' + fileTypes [ i ] ) ;
35
+ customFileTypePath = customFileTypePath . substr ( 0 , customFileTypePath . lastIndexOf ( "." ) ) + '.' + fileType ;
36
+ var customFileTypeOutputPath = patternlab . config . paths . public . patterns + pattern . getPatternLink ( patternlab , 'custom' , '.' + fileType ) ;
34
37
35
38
//look for a custom filetype for this template
36
39
try {
0 commit comments