From e0c477a46f1c0a7cce54e21d349d8933f896f793 Mon Sep 17 00:00:00 2001 From: jay Date: Tue, 27 Apr 2021 11:47:25 +0500 Subject: [PATCH] feat: :hammer: make `fs.watch` recursive, so it `reloadplugin` works also on directories --- lib/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index 9c102d4..ec205ec 100644 --- a/lib/index.js +++ b/lib/index.js @@ -58,7 +58,7 @@ function unloadplugin(pluginname, pluginpath) { } } -reloadplugin = (event, filename, pluginpath) => { +function reloadplugin(event, filename, pluginpath) { if (!/\.js$/.test(filename)) { return } if (!cfg.fsTimeout) { console.info(event, filename) @@ -85,7 +85,7 @@ reloadplugin = (event, filename, pluginpath) => { // console.log('file.js %s event', event) } -fs.watch('./lib/plugins', reloadplugin) +fs.watch('./lib/plugins', { recursive: true }, reloadplugin) cfg.bot = bot // TODO better name, or switch to array