npm install --save @amory/src-fs-watch #+end_src
npm install @amory/src-fs-watch* @amory/src-fs-watch
** Overview
The intention of this package is to provide a single process and interface for all desired file watching activities. Only file changes and deletions are reported. Saving files without changing their content are [intentionally] not reported. Consumers receive all reported file events starting with the beginning of the file watching process. Events can easily be filtered using any method supported by RxJs =.pipe=, e.g. =filter=, =map=, =reduce=, etc.
** Install
#+begin_src sh
npm install --save @amory/src-fs-watch
#+end_src
** Example
#+begin_src js
const srcFsWatch = require ("@amory/src-fs-watch")
const { join } = require ("path").posix
const { filter } = require ("rxjs/operators")
// Any valid chokidar options (plus src) can be passed here:
const watcher = srcFsWatch ({
"src": join (process.cwd (), "src")
})
watcher
.pipe (filter (({ src }) => /\.js(on)?$/.test (src)))
.subscribe ({
"next": ({ evt, src }) => console.log (evt, src)
})
#+end_src
** Credits
Inspired by original code and concepts from:
- [[https://github.com/DeMoorJasper/fswatcher-child][DeMoorJasper/fswatcher-child]]
- [[https://github.com/tools-rx/watch-rx][tools-rx/watch-rx]]
- [[https://github.com/webpack/watchpack][webpack/watchpack]]