diff --git a/app.js b/app.js index ed8fd2e661..194f0edb3a 100644 --- a/app.js +++ b/app.js @@ -81,14 +81,25 @@ if (!nconf.get('help') && !nconf.get('setup') && !nconf.get('install') && !nconf resetThemes(); } else if (nconf.get('plugins')) { resetPlugins(); + } else if (nconf.get('widgets')) { + resetWidgets(); } else if (nconf.get('all')) { - require('async').parallel([resetThemes, resetPlugins], function(err) { - if (!err) { - winston.info('[reset] Reset complete.'); + resetWidgets(function(err) { + if (err) { + winston.error('[reset] Errors were encountered while resetting widget areas: ' + err.message); + process.exit(); } else { - winston.error('[reset] Errors were encountered while resetting your forum settings: ' + err.message); + winston.info('[reset] All Widgets moved to Draft Zone'); } - process.exit(); + + require('async').parallel([resetThemes, resetPlugins], function(err) { + if (!err) { + winston.info('[reset] Reset complete.'); + } else { + winston.error('[reset] Errors were encountered while resetting your forum settings: ' + err.message); + } + process.exit(); + }); }); } else { console.log('no match'); @@ -251,6 +262,16 @@ function resetPlugins(callback) { }); } +function resetWidgets(callback) { + loadConfig(); + + var db = require('./src/database'); + + db.init(function() { + require('./src/widgets').reset(callback); + }); +} + function shutdown(code) { winston.info('[app] Shutdown (SIGTERM/SIGINT) Initialised.'); require('./src/database').close();