@@ -37,8 +37,12 @@ function acquireBuild(){
37
37
return true
38
38
}
39
39
}
40
- var sourcedirs = path . join ( 'lib' , 'bs' , ".sourcedirs.json" )
41
- function watch_build ( watch_files ) {
40
+ var sourcedirs = path . join ( 'lib' , 'bs' , '.sourcedirs.json' )
41
+ var watch_generated = [ ]
42
+
43
+ function watch_build ( watch_config ) {
44
+ var watch_files = watch_config . dirs
45
+ watch_generated = watch_config . generated
42
46
// close and remove all unused watchers
43
47
watchers = watchers . filter ( function ( watcher ) {
44
48
if ( watcher . dir === bsconfig ) {
@@ -78,7 +82,10 @@ function validEvent(eventType,fileName){
78
82
if ( ! fileName )
79
83
return true ;
80
84
81
- return ! ( fileName === '.merlin' || fileName . endsWith ( '.js' ) )
85
+ return ! ( fileName === '.merlin' ||
86
+ fileName . endsWith ( '.js' ) ||
87
+ watch_generated . indexOf ( fileName ) >= 0
88
+ )
82
89
}
83
90
/**
84
91
* @return {boolean }
@@ -113,11 +120,7 @@ function build() {
113
120
*/
114
121
function on_change ( event , reason ) {
115
122
if ( validEvent ( event , reason ) ) {
116
- < << << << 864 d25584eb7e9f72c074a3ff0b277c48750e4bf
117
123
console . log ( "Event" , event , reason ) ;
118
- = === ===
119
- console . log ( "Event" , event , reason ) ;
120
- > >>> >>> wip
121
124
reasons_to_rebuild . push ( [ event , reason ] )
122
125
if ( needRebuild ( ) ) {
123
126
build ( )
@@ -129,13 +132,13 @@ function getWatchFiles(file) {
129
132
if ( fs . existsSync ( file ) ) {
130
133
return JSON . parse ( fs . readFileSync ( file , 'utf8' ) )
131
134
} else {
132
- return [ ]
135
+ return { dirs : [ ] , generated : [ ] }
133
136
}
134
137
135
138
}
136
139
137
140
138
- // Initialization, watch `bsconfig.json`
139
- watchers . push ( { watcher : fs . watch ( bsconfig , on_change ) , dir : bsconfig } ) ;
141
+ // Initialization
140
142
143
+ watchers . push ( { watcher : fs . watch ( bsconfig , on_change ) , dir : bsconfig } ) ;
141
144
build ( ) ;
0 commit comments