node package manager


ls meets tail -f


ls meets tail -f

var watcher = require('watch-stream')
watcher(process.cwd(), opts)
  .search(/mp3$/) //returns a stream! 
  .on('data', console.log)

wraps mikeal

returns a WatchStream on all the flies under root.

return a WatchStream of flies that match the string or regexp.

data objects look like this:

{ name: 'Charisma/Disasteradio - Charisma - 05 Gravy Rainbow.mp3',
  create: true,
  type: 'file',
  size: 5598948,
  mtime: '2012-09-14T13:51:57.000Z',
  ctime: '2012-09-14T14:37:51.000Z' }

type it taken off the stat object, see fs.Stats it corrisponds thusly:

    return (
        curr.isFile()            ? 'file'
      : curr.isDirectory()       ? 'dir'
      : curr.isBlockDevice()     ? 'blocks'
      : curr.isCharacterDevice() ? 'chars'
      : curr.isSymbolicLink()    ? 'symlink'
      : curr.isFIFO()            ? 'fifo'
      : curr.isSocket()          ? 'socket' 
      :                            undefined

stop listening on changes

File watching is more or less broken in some way or another on each platfrom.


and there are other tricky cases, like when a directory is moved. (now, the dir file still exists, but the names for the it's files are now all different)