Skip to content

Commit 3d9e4eb

Browse files
committed
ignore generated files in watcher
1 parent 2bc47f2 commit 3d9e4eb

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

jscomp/bin/bsb_watcher.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,12 @@ function acquireBuild(){
3737
return true
3838
}
3939
}
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
4246
// close and remove all unused watchers
4347
watchers = watchers.filter(function(watcher){
4448
if(watcher.dir === bsconfig){
@@ -78,7 +82,10 @@ function validEvent(eventType,fileName){
7882
if (!fileName)
7983
return true;
8084

81-
return !(fileName === '.merlin' || fileName.endsWith('.js'))
85+
return !(fileName === '.merlin' ||
86+
fileName.endsWith('.js') ||
87+
watch_generated.indexOf(fileName) >= 0
88+
)
8289
}
8390
/**
8491
* @return {boolean}
@@ -113,11 +120,7 @@ function build() {
113120
*/
114121
function on_change(event, reason) {
115122
if(validEvent(event,reason)){
116-
<<<<<<< 864d25584eb7e9f72c074a3ff0b277c48750e4bf
117123
console.log("Event", event,reason);
118-
=======
119-
console.log("Event", event, reason);
120-
>>>>>>> wip
121124
reasons_to_rebuild.push([event, reason])
122125
if(needRebuild()){
123126
build()
@@ -129,13 +132,13 @@ function getWatchFiles(file) {
129132
if (fs.existsSync(file)){
130133
return JSON.parse(fs.readFileSync(file, 'utf8'))
131134
} else {
132-
return []
135+
return { dirs : [], generated : []}
133136
}
134137

135138
}
136139

137140

138-
// Initialization, watch `bsconfig.json`
139-
watchers.push({watcher : fs.watch(bsconfig,on_change) , dir : bsconfig});
141+
// Initialization
140142

143+
watchers.push({watcher : fs.watch(bsconfig,on_change) , dir : bsconfig});
141144
build();

0 commit comments

Comments
 (0)