@@ -11,7 +11,7 @@ const asset_copier = () => {
11
11
const transform_paths = ( directories ) => {
12
12
//create array with all source keys minus our blacklist
13
13
const dirs = { } ;
14
- const blackList = [ 'root' , 'patterns' , 'data' , 'meta' , 'annotations' , 'styleguide' , ' patternlabFiles'] ;
14
+ const blackList = [ 'root' , 'patterns' , 'data' , 'meta' , 'annotations' , 'patternlabFiles' ] ;
15
15
_ . each ( directories . source , ( dir , key ) => {
16
16
17
17
if ( blackList . includes ( key ) ) {
@@ -66,13 +66,18 @@ const asset_copier = () => {
66
66
} ;
67
67
68
68
//loop through each directory asset object (source / public pairing)
69
- _ . each ( dirs , ( dir ) => {
69
+ _ . each ( dirs , ( dir , key ) => {
70
70
71
71
//if we want to watch files, do so, otherwise just copy each file
72
72
if ( options . watch ) {
73
73
if ( patternlab . config . debug ) {
74
74
console . log ( `Pattern Lab is watching ${ path . resolve ( basePath , dir . source ) } for changes` ) ;
75
75
}
76
+
77
+ if ( patternlab . watchers [ key ] ) {
78
+ patternlab . watchers [ key ] . close ( ) ;
79
+ }
80
+
76
81
const assetWatcher = chokidar . watch (
77
82
path . resolve ( basePath , dir . source ) ,
78
83
{
@@ -97,13 +102,21 @@ const asset_copier = () => {
97
102
copyFile ( p , destination , copyOptions ) ;
98
103
} ) ;
99
104
105
+ patternlab . watchers [ key ] = assetWatcher ;
106
+
100
107
} else {
101
108
//just copy
102
109
const destination = path . resolve ( basePath , dir . public ) ;
103
110
copyFile ( dir . source , destination , copyOptions ) ;
104
111
}
105
112
} ) ;
106
113
114
+ // copy the styleguide
115
+ copyFile ( assetDirectories . source . styleguide , assetDirectories . public . root , copyOptions ) ;
116
+
117
+ // copy the favicon
118
+ copyFile ( `${ assetDirectories . source . root } /favicon.ico` , `${ assetDirectories . public . root } /favicon.ico` , copyOptions ) ;
119
+
107
120
//we need to special case patterns/**/*.md|.json|.pattern-extensions as well as the global structures
108
121
if ( options . watch ) {
109
122
@@ -121,6 +134,10 @@ const asset_copier = () => {
121
134
console . log ( `Pattern Lab is watching ${ globalPath } for changes` ) ;
122
135
}
123
136
137
+ if ( patternlab . watchers [ globalPath ] ) {
138
+ patternlab . watchers [ globalPath ] . close ( ) ;
139
+ }
140
+
124
141
const globalWatcher = chokidar . watch (
125
142
path . resolve ( globalPath ) ,
126
143
{
@@ -150,6 +167,8 @@ const asset_copier = () => {
150
167
} ) ;
151
168
} ) ;
152
169
170
+ patternlab . watchers [ globalPath ] = globalWatcher ;
171
+
153
172
} ) ;
154
173
155
174
// watch patterns
0 commit comments