Use a private utility function to wait for all native watchers to stop

This commit is contained in:
Ash Wilson
2017-06-21 10:24:06 -04:00
parent 12c961c8b9
commit be681d1324
3 changed files with 12 additions and 8 deletions

View File

@@ -46,7 +46,7 @@ TextBuffer = require 'text-buffer'
Gutter = require './gutter'
TextEditorRegistry = require './text-editor-registry'
AutoUpdateManager = require './auto-update-manager'
FileSystemManager = require './filesystem-manager'
FileSystemManager = require('./filesystem-manager').default
# Essential: Atom global for dealing with packages, themes, menus, and the window.
#

View File

@@ -222,3 +222,11 @@ export default class FileSystemManager {
return watcher
}
}
// Private: Return a Promise that resolves when all {NativeWatcher} instances associated with a FileSystemManager
// have stopped listening. This is useful for `afterEach()` blocks in unit tests.
export function stopAllWatchers (manager) {
return Promise.all(
Array.from(manager.liveWatchers, watcher => watcher.stop())
)
}