mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-20 07:28:08 +03:00
Use a private utility function to wait for all native watchers to stop
This commit is contained in:
parent
12c961c8b9
commit
be681d1324
@ -6,7 +6,7 @@ import fsCb from 'fs-plus'
|
||||
import path from 'path'
|
||||
|
||||
import {CompositeDisposable} from 'event-kit'
|
||||
import FileSystemManager from '../src/filesystem-manager'
|
||||
import FileSystemManager, {stopAllWatchers} from '../src/filesystem-manager'
|
||||
|
||||
tempCb.track()
|
||||
|
||||
@ -24,12 +24,8 @@ describe('FileSystemManager', function () {
|
||||
afterEach(async function () {
|
||||
subs.dispose()
|
||||
|
||||
const cleanup = [temp.cleanup()]
|
||||
const nativeWatchers = manager.nativeWatchers.tree.leaves().map(node => node.getNativeWatcher())
|
||||
for (const native of nativeWatchers) {
|
||||
cleanup.push(native.stop())
|
||||
}
|
||||
await Promise.all(cleanup)
|
||||
await stopAllWatchers(manager)
|
||||
await temp.cleanup()
|
||||
})
|
||||
|
||||
function waitForEvent (fn) {
|
||||
|
@ -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.
|
||||
#
|
||||
|
@ -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())
|
||||
)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user