paranormal
Version:
Phenomenal Code Examples
34 lines (23 loc) • 955 B
JavaScript
;
exports.__esModule = true;
var _events = require('events');
var _events2 = _interopRequireDefault(_events);
var _fs = require('./utils/fs');
var fs = _interopRequireWildcard(_fs);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
class Watcher extends _events2.default {
watch(dirPath) {
let watcher = fs.watchDirectory(dirPath);
watcher.on('add', filePath => {
this.emit('add', filePath);
});
watcher.on('unlink', filePath => {
this.emit('remove', filePath);
});
watcher.on('change', filePath => {
this.emit('change', filePath);
});
}
}
exports.default = Watcher;