@@ -26,35 +26,34 @@ function findTab(patternlab, pattern) {
26
26
}
27
27
28
28
//derive the custom filetype paths from the pattern relPath
29
- var customFileTypePath = path . join ( patternlab . config . paths . source . patterns , pattern . relPath ) ;
29
+ let customFileTypePath = path . join ( patternlab . config . paths . source . patterns , pattern . relPath ) ;
30
30
31
31
//loop through all configured types
32
32
for ( let i = 0 ; i < fileTypes . length ; i ++ ) {
33
33
const fileType = fileTypes [ i ] . toLowerCase ( ) ;
34
34
35
35
customFileTypePath = customFileTypePath . substr ( 0 , customFileTypePath . lastIndexOf ( "." ) ) + '.' + fileType ;
36
- var customFileTypeOutputPath = patternlab . config . paths . public . patterns + pattern . getPatternLink ( patternlab , 'custom' , '.' + fileType ) ;
36
+ let customFileTypeOutputPath = patternlab . config . paths . public . patterns + pattern . getPatternLink ( patternlab , 'custom' , '.' + fileType ) ;
37
37
38
- //look for a custom filetype for this template
39
38
try {
40
- try {
41
- var tabFileName = path . resolve ( customFileTypePath ) ;
42
- var tabFileNameStats = fs . statSync ( tabFileName ) ;
43
- } catch ( err ) {
44
- //not a file - move on quietly
45
- }
46
- fs . pathExistsSync ( tabFileName , ( err , exists ) => {
47
- if ( exists ) {
39
+ let tabFileName = path . resolve ( customFileTypePath ) ;
40
+ let tabFileNameOutput = path . resolve ( customFileTypeOutputPath ) ;
41
+
42
+ //look for a custom filetype for this template
43
+ fs . pathExists ( tabFileName , ( err , exists ) => {
44
+ if ( exists === true ) {
48
45
if ( patternlab . config . debug ) {
49
46
console . log ( 'plugin-node-tab: copied pattern-specific ' + fileType + ' file for ' + pattern . patternPartial ) ;
50
47
}
51
48
52
49
//copy the file to our output target if found
53
- fs . copySync ( tabFileName , customFileTypeOutputPath ) ;
50
+ fs . copy ( tabFileName , tabFileNameOutput , { overwrite : true } ) ;
54
51
} else {
55
-
52
+ if ( patternlab . config . debug ) {
53
+ console . log ( 'plugin-node-tab: empty ' + fileType + ' file for ' + pattern . patternPartial + ' to prevent GET error' ) ;
54
+ }
56
55
//otherwise write nothing to the same location - this prevents GET errors on the tab.
57
- fs . outputFileSync ( customFileTypeOutputPath , '' ) ;
56
+ fs . outputFile ( customFileTypeOutputPath , '' ) ;
58
57
}
59
58
} ) ;
60
59
0 commit comments