diff options
-rwxr-xr-x | twittperator.js | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/twittperator.js b/twittperator.js index 64c84a0..6883b24 100755 --- a/twittperator.js +++ b/twittperator.js @@ -1360,16 +1360,21 @@ function sourceScriptFile(file) { // {{{ } } // }}} function loadPlugins() { // {{{ - function getVariableName(file) - file.leafName.replace(/\..*/, "").replace(/-/g, "_"); - - io.getRuntimeDirectories("plugin/twittperator").forEach(function(dir) { - dir.readDirectory().forEach(function(file) { - let name = getVariableName(file); - if (/\.tw$/(file.path) && liberator.globalVariables["twittperator_plugin_" + name]) - sourceScriptFile(file); - }); - }); + function isEnabled(file) + let (name = file.leafName.replace(/\..*/, "").replace(/-/g, "_")) + liberator.globalVariables["twittperator_plugin_" + name]; + + function loadPluginFromDir(checkGV) { + return function(dir) { + dir.readDirectory().forEach(function(file) { + if (/\.tw$/(file.path) && (!checkGV || isEnabled(file))) + sourceScriptFile(file); + }); + } + } + + io.getRuntimeDirectories("plugin/twittperator").forEach(loadPluginFromDir(true)); + io.getRuntimeDirectories("twittperator").forEach(loadPluginFromDir(false)); } // }}} function setup() { // {{{ function commandCompelter(context, args) { |