index.js 858 B

1234567891011121314151617181920212223242526272829
  1. 'use strict';
  2. var NodeWatcher = require('./src/node_watcher');
  3. var PollWatcher = require('./src/poll_watcher');
  4. var WatchmanWatcher = require('./src/watchman_watcher');
  5. var FSEventsWatcher = require('./src/fsevents_watcher');
  6. function sane(dir, options) {
  7. options = options || {};
  8. if (options.watcher) {
  9. var WatcherClass = require(options.watcher);
  10. return new WatcherClass(dir, options);
  11. } else if (options.poll) {
  12. return new PollWatcher(dir, options);
  13. } else if (options.watchman) {
  14. return new WatchmanWatcher(dir, options);
  15. } else if (options.fsevents) {
  16. return new FSEventsWatcher(dir, options);
  17. } else {
  18. return new NodeWatcher(dir, options);
  19. }
  20. }
  21. module.exports = sane;
  22. sane.NodeWatcher = NodeWatcher;
  23. sane.PollWatcher = PollWatcher;
  24. sane.WatchmanWatcher = WatchmanWatcher;
  25. sane.FSEventsWatcher = FSEventsWatcher;