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

Commit 06c7892

Browse files
committed
fix issue with wrong read location for filetypes
1 parent e2ce505 commit 06c7892

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/tab-loader.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
"use strict";
22

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');
65

76
/**
87
* The backend method that is called during the patternlab-pattern-write-end event.
@@ -12,6 +11,9 @@ const fs = require('fs-extra'),
1211
*/
1312
function findTab(patternlab, pattern) {
1413

14+
//read the filetypes from the configuration
15+
const fileTypes = patternlab.config.plugins['plugin-node-tab'].options.tabsToAdd;
16+
1517
//exit if either of these two parameters are missing
1618
if (!patternlab) {
1719
console.error('plugin-node-tab: patternlab object not provided to findTab');
@@ -28,9 +30,10 @@ function findTab(patternlab, pattern) {
2830

2931
//loop through all configured types
3032
for (let i = 0; i < fileTypes.length; i++) {
33+
const fileType = fileTypes[i].toLowerCase();
3134

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);
3437

3538
//look for a custom filetype for this template
3639
try {

0 commit comments

Comments
 (0)