Skip to content

Node.js based forum software built for the modern web

split reset into themes, plugins, and all -- #1317

Julian Lam320f187829ad
diff --git a/app.js b/app.js
index 00675e0a30..ed8fd2e661 100644
--- a/app.js
+++ b/app.js
@@ -77,7 +77,22 @@ if (!nconf.get('help') && !nconf.get('setup') && !nconf.get('install') && !nconf
} else if (nconf.get('upgrade')) {
upgrade();
} else if (nconf.get('reset')) {
- reset();
+ if (nconf.get('themes')) {
+ resetThemes();
+ } else if (nconf.get('plugins')) {
+ resetPlugins();
+ } else if (nconf.get('all')) {
+ 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');
+ }
} else {
displayHelp();
}
@@ -198,40 +213,40 @@ function upgrade() {
});
}
-function reset() {
+function resetThemes(callback) {
loadConfig();
- var meta = require('./src/meta'),
- db = require('./src/database'),
- async = require('async');
+ var db = require('./src/database'),
+ meta = require('./src/meta');
+
+ db.init(function() {
+ meta.themes.set({
+ type: 'local',
+ id: 'nodebb-theme-vanilla'
+ }, function(err) {
+ winston.info('[reset] Theme reset to Vanilla');
+ if (typeof callback === 'function') {
+ callback(err);
+ } else {
+ process.exit();
+ }
+ });
+ });
+}
+
+function resetPlugins(callback) {
+ loadConfig();
- db.init(function(err) {
- meta.configs.init(function () {
- async.parallel([
- function(next) {
- db.delete('plugins:active', next);
- },
- function(next) {
- meta.configs.set('theme:type', 'local', next);
- },
- function(next) {
- meta.configs.set('theme:id', 'nodebb-theme-vanilla', next);
- },
- function(next) {
- meta.configs.set('theme:staticDir', '', next);
- },
- function(next) {
- meta.configs.set('theme:templates', '', next);
- }
- ], function(err) {
- if (err) {
- winston.error(err);
- } else {
- winston.info("Successfully reset theme to Vanilla and disabled all plugins.");
- }
+ var db = require('./src/database');
+ db.init(function() {
+ db.delete('plugins:active', function(err) {
+ winston.info('[reset] All Plugins De-activated');
+ if (typeof callback === 'function') {
+ callback(err);
+ } else {
process.exit();
- });
+ }
});
});
}
diff --git a/nodebb b/nodebb
index b67b4ba0db..18f6df8966 100755
--- a/nodebb
+++ b/nodebb
@@ -71,7 +71,7 @@ case "$1" in
;;
reset)
- node loader --reset
+ node loader --reset --$2
;;
dev)