Merge pull request #439 from embark-framework/uv_close_fix

only close watcher when it's actually ready
This commit is contained in:
Iuri Matias 2018-05-18 14:51:05 -04:00 committed by GitHub
commit db6b90e77f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -41,8 +41,9 @@ class Watch {
stop() {
this.fileWatchers.forEach(fileWatcher => {
fileWatcher.close();
fileWatcher = null;
if (fileWatcher.shouldClose) return;
if (fileWatcher.isReady) fileWatcher.close();
fileWatcher.shouldClose = true;
});
this.fileWatchers = [];
}
@ -125,7 +126,11 @@ class Watch {
.on('add', path => changeCallback('add', path))
.on('change', path => changeCallback('change', path))
.on('unlink', path => changeCallback('remove', path))
.on('ready', doneCallback);
.once('ready', () => {
configWatcher.isReady = true;
if (configWatcher.shouldClose) configWatcher.close();
doneCallback();
});
}
}