v1.18.x
Julian Lam 8 years ago
parent cbd6853ccb
commit ad732935fb

@ -73,7 +73,12 @@ if (nconf.get('setup') || nconf.get('install')) {
} else if (nconf.get('upgrade')) { } else if (nconf.get('upgrade')) {
upgrade(); upgrade();
} else if (nconf.get('reset')) { } else if (nconf.get('reset')) {
require('./src/reset').reset(); async.waterfall([
async.apply(require('./src/reset').reset),
async.apply(require('./build').build, true)
], function (err) {
process.exit(err ? 1 : 0);
});
} else if (nconf.get('activate')) { } else if (nconf.get('activate')) {
activate(); activate();
} else if (nconf.get('plugins')) { } else if (nconf.get('plugins')) {

@ -8,7 +8,7 @@ var db = require('./database');
var Reset = {}; var Reset = {};
Reset.reset = function () { Reset.reset = function (callback) {
db.init(function (err) { db.init(function (err) {
if (err) { if (err) {
winston.error(err.message); winston.error(err.message);
@ -17,20 +17,20 @@ Reset.reset = function () {
if (nconf.get('t')) { if (nconf.get('t')) {
if(nconf.get('t') === true) { if(nconf.get('t') === true) {
resetThemes(); resetThemes(callback);
} else { } else {
resetTheme(nconf.get('t')); resetTheme(nconf.get('t'), callback);
} }
} else if (nconf.get('p')) { } else if (nconf.get('p')) {
if (nconf.get('p') === true) { if (nconf.get('p') === true) {
resetPlugins(); resetPlugins(callback);
} else { } else {
resetPlugin(nconf.get('p')); resetPlugin(nconf.get('p'), callback);
} }
} else if (nconf.get('w')) { } else if (nconf.get('w')) {
resetWidgets(); resetWidgets(callback);
} else if (nconf.get('s')) { } else if (nconf.get('s')) {
resetSettings(); resetSettings(callback);
} else if (nconf.get('a')) { } else if (nconf.get('a')) {
require('async').series([resetWidgets, resetThemes, resetPlugins, resetSettings], function (err) { require('async').series([resetWidgets, resetThemes, resetPlugins, resetSettings], function (err) {
if (!err) { if (!err) {
@ -38,7 +38,12 @@ Reset.reset = function () {
} else { } else {
winston.error('[reset] Errors were encountered while resetting your forum settings: %s', err.message); winston.error('[reset] Errors were encountered while resetting your forum settings: %s', err.message);
} }
process.exit();
if (typeof callback === 'function') {
callback();
} else {
process.exit(0);
}
}); });
} else { } else {
process.stdout.write('\nNodeBB Reset\n'.bold); process.stdout.write('\nNodeBB Reset\n'.bold);
@ -52,6 +57,7 @@ Reset.reset = function () {
process.stdout.write('\nPlugin and theme reset flags (-p & -t) can take a single argument\n'); process.stdout.write('\nPlugin and theme reset flags (-p & -t) can take a single argument\n');
process.stdout.write(' e.g. ./nodebb reset -p nodebb-plugin-mentions, ./nodebb reset -t nodebb-theme-persona\n'); process.stdout.write(' e.g. ./nodebb reset -p nodebb-plugin-mentions, ./nodebb reset -t nodebb-theme-persona\n');
process.exit(); process.exit();
} }
}); });
@ -69,7 +75,7 @@ function resetSettings(callback) {
}); });
} }
function resetTheme(themeId) { function resetTheme(themeId, callback) {
var meta = require('./meta'); var meta = require('./meta');
var fs = require('fs'); var fs = require('fs');
@ -88,7 +94,11 @@ function resetTheme(themeId) {
winston.info('[reset] Theme reset to ' + themeId); winston.info('[reset] Theme reset to ' + themeId);
} }
process.exit(); if (typeof callback === 'function') {
callback();
} else {
process.exit(0);
}
}); });
} }
}); });
@ -105,12 +115,12 @@ function resetThemes(callback) {
if (typeof callback === 'function') { if (typeof callback === 'function') {
callback(err); callback(err);
} else { } else {
process.exit(); process.exit(0);
} }
}); });
} }
function resetPlugin(pluginId) { function resetPlugin(pluginId, callback) {
var active = false; var active = false;
async.waterfall([ async.waterfall([
@ -136,7 +146,11 @@ function resetPlugin(pluginId) {
} }
} }
process.exit(); if (typeof callback === 'function') {
callback();
} else {
process.exit(0);
}
}); });
} }
@ -146,7 +160,7 @@ function resetPlugins(callback) {
if (typeof callback === 'function') { if (typeof callback === 'function') {
callback(err); callback(err);
} else { } else {
process.exit(); process.exit(0);
} }
}); });
} }

Loading…
Cancel
Save