/* @flow */

const AtomWatcher = require('./atom_watcher')
const ChokidarWatcher = require('./chokidar_watcher')

/*::
import type Pouch from '../pouch'
import type Prep from '../prep'
import type EventEmitter from 'events'
import type { Ignore } from '../ignore'
import type { ChokidarEvent } from './chokidar_event'
import type { Checksumer } from './checksumer'

type WatcherType = 'atom' | 'chokidar'

export interface Watcher {
  checksumer: Checksumer,
  running: Promise<*>,
  start (): Promise<*>,
  stop (force: ?bool): Promise<*>,
}
*/

function build (config /*: { +syncPath: string, +watcherType: string } */, prep /*: Prep */, pouch /*: Pouch */, events /*: EventEmitter */, ignore /*: Ignore */) /*: Watcher */ {
  const { syncPath, watcherType } = config

  if (watcherType === 'atom') {
    return new AtomWatcher(syncPath, prep, pouch, events, ignore)
  } else {
    return new ChokidarWatcher(syncPath, prep, pouch, events)
  }
}

module.exports = { build }

@@ -112,16 +112,61 @@
 )%0A%0A/*::%0A
+import type %7B WatcherType %7D from '../config'%0A
 import t
@@ -191,16 +191,16 @@
 /pouch'%0A
-
 import t
@@ -408,48 +408,8 @@
 r'%0A%0A
-type WatcherType = 'atom' %7C 'chokidar'%0A%0A
 expo
@@ -607,22 +607,27 @@
 erType: 
-string
+WatcherType
  %7D */, p

Use WatcherType from core/config