/* @flow */

const metadata = require('../../../core/metadata')
const events = require('../../../core/local/steps/event')

/*::
import type { Stats } from 'fs'
import type { AtomWatcherEvent, EventAction, EventKind, Batch } from '../../../core/local/steps/event'
*/

function randomPick /*:: <T> */ (elements /*: Array<T> */) /*: T */{
  const l = elements.length
  const i = Math.floor(Math.random() * l)
  return elements[i]
}

module.exports = class AtomWatcherEventBuilder {
  /*::
  _event: AtomWatcherEvent
  */

  constructor () {
    this._event = {
      action: randomPick(events.ACTIONS),
      kind: randomPick(events.KINDS),
      path: '/',
      _id: '/'
    }
  }

  build () /*: AtomWatcherEvent */ {
    return this._event
  }

  action (newAction /*: EventAction */) /*: this */ {
    this._event.action = newAction
    return this
  }

  kind (newKind /*: EventKind */) /*: this */ {
    this._event.kind = newKind
    return this
  }

  path (newPath /*: string */) /*: this */ {
    this._event.path = newPath
    this._event._id = metadata.id(newPath)
    return this
  }

  oldPath (newPath /*: string */) /*: this */{
    this._event.oldPath = newPath
    return this
  }

  id (newId /*: string */) /*: this */ {
    this._event._id = newId
    return this
  }

  stats (newStats /*: Stats */) /*: this */ {
    this._event.stats = newStats
    return this
  }

  md5sum (newMd5sum /*: string */) /*: this */ {
    this._event.md5sum = newMd5sum
    return this
  }

  noIgnore () /*: this */ {
    this._event.noIgnore = true
    return this
  }
}

@@ -6,16 +6,42 @@
 low */%0A%0A
+const fs = require('fs')%0A%0A
 const me
@@ -1329,21 +1329,32 @@
 ats /*: 
-Stats
+%7B ino?: number %7D
  */) /*:
@@ -1356,32 +1356,123 @@
 ) /*: this */ %7B%0A
+    const stats /*: Stats */ = fs.statSync(__filename)%0A    Object.assign(stats, newStats)%0A%0A
     this._event.
@@ -1479,20 +1479,17 @@
 stats = 
-newS
+s
 tats%0A   

Fix event builder stats()