Comparing version 1.0.1 to 1.0.2
@@ -10,2 +10,3 @@ const path = require('path'); | ||
const scandir = require('./scandir'); | ||
const scandirSync = require('./scandirSync'); | ||
@@ -87,4 +88,23 @@ const handleError = require('./handleError'); | ||
/** | ||
* Watchers autoloader | ||
* Read files in the dir dirrectory, and add watchers from them to redbone watch | ||
* @param {String} dir path to dir | ||
* @return {Function} redbone function to chain | ||
*/ | ||
redbone.readWatchersSync = function readWatchersSync(dir) { | ||
scandirSync(dir, function(file) { | ||
const watchers = require(path.join(dir, file)); | ||
if (!isArray(watchers)) throw new RedboneError('Watchers is not an array'); | ||
watchers.forEach((watcher) => { | ||
if (!(watcher.type && isString(watcher.type))) throw new RedboneError('Watcher type is not defined'); | ||
if (!(watcher.action && isFunction(watcher.action))) throw new RedboneError('Watcher action is not defined'); | ||
redbone.watch(watcher.type, watcher.action); | ||
}); | ||
}); | ||
return redbone; | ||
} | ||
redbone.dispatcher = dispatcher; | ||
redbone.Socket = Socket; | ||
redbone.RedboneError = RedboneError; |
{ | ||
"name": "redbone", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13187
14
294
5