watch-interface
v0.4.0
Published
Recursively gather file meta data starting at a root directory. An interface to other file watching libs (currently mainly gaze).
Downloads
10
Readme
watch-interface
Recursively gather file meta data starting at a root directory. When files change the meta data gets automatically updated. It is thin wrapper for gaze that takes care of some housekeeping and provides a non-changing interface when we change the watching backend.
Usage
require('watch-interface').on(directory, options, callback)
Starts watching a directory recursively.
directory
: String, root of what should be watchedoptions
: Object withexclude
: Array of strings, regular expressions or functions that should match if the particular file should be ignored.
callback
: gets err object and agazer
require('watch-interface').onFiles(directory, listOfFiles, options, callback)
Like on but ignore all files except those that are in the list.
gazer.state
- object with the fields
monitor
: gazer object from thegaze
modulelastChange
: DatestartTime
: DatechangeList
: list of changes accrued sincestartTime
, having the fields:time
path
type
: one of["creation", "removal", "change"]
gazer.getWatchedFiles(callback)
Retrieve all the files being watched.
callback
is called with an error object and and array of files (file paths, relative to the base directory being watched)
gazer.getChangesSince(date, callback)
Retrieve what changes happened since a given time.
date
: Request changes since. Date object or Number specifying a data. If null, returns all changes observed.callback
is called with two args:err
and[{time,path,type}]
with type one of['removal', 'creation', 'change']
gazer.close(callback)
Stop watching.
callback
: gets err argument.