Node.js based forum software built for the modern web
added plugins.showInstalled method
Julian Lam307f6f34b924
diff --git a/src/plugins.js b/src/plugins.jsindex d6c5a6db79..cc52ffa017 100644--- a/src/plugins.js+++ b/src/plugins.js@@ -110,6 +110,43 @@ var fs = require('fs'),break;}}+ },+ showInstalled: function() {+ // TODO: Also check /node_modules+ var moduleBasePath = path.join(__dirname, '../plugins');++ async.waterfall([+ function(next) {+ fs.readdir(moduleBasePath, next);+ },+ function(files, next) {+ var plugins = [];++ async.each(files, function(file, next) {+ var modulePath = path.join(moduleBasePath, file),+ configPath;++ fs.stat(path.join(moduleBasePath, file), function(err, stats) {+ if (err || !stats.isDirectory()) return next(); //Silently fail++ // Load the config file+ fs.readFile(path.join(modulePath, 'plugin.json'), function(err, configJSON) {+ if (err) return next(); // Silently fail if config can't be read+ var config = JSON.parse(configJSON);+ delete config.library;+ delete config.hooks;++ plugins.push(config);+ next();+ });+ });+ }, function(err) {+ next(null, plugins);+ });+ }+ ], function(err, plugins) {+ console.log('plugins:', plugins);+ });}}