mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 19:15:58 +01:00 
			
		
		
		
	fix: cli/reset.js (#7979)
This commit is contained in:
		
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							95a372df85
						
					
				
				
					commit
					f9f85fc425
				
			| @@ -3,7 +3,6 @@ | |||||||
| require('colors'); | require('colors'); | ||||||
| const path = require('path'); | const path = require('path'); | ||||||
| const winston = require('winston'); | const winston = require('winston'); | ||||||
| const async = require('async'); |  | ||||||
| const fs = require('fs'); | const fs = require('fs'); | ||||||
| const util = require('util'); | const util = require('util'); | ||||||
|  |  | ||||||
| @@ -123,55 +122,38 @@ async function resetThemeTo(themeId) { | |||||||
| 	winston.info('[reset] Theme reset to ' + themeId + ' and default skin'); | 	winston.info('[reset] Theme reset to ' + themeId + ' and default skin'); | ||||||
| } | } | ||||||
|  |  | ||||||
| function resetPlugin(pluginId, callback) { | async function resetPlugin(pluginId) { | ||||||
| 	var active = false; | 	try { | ||||||
|  | 		const isActive = await db.isSortedSetMember('plugins:active', pluginId); | ||||||
|  | 		if (isActive) { | ||||||
|  | 			await db.sortedSetRemove('plugins:active', pluginId); | ||||||
|  | 		} | ||||||
|  |  | ||||||
| 	async.waterfall([ | 		await events.log({ | ||||||
| 		async.apply(db.isSortedSetMember, 'plugins:active', pluginId), | 			type: 'plugin-deactivate', | ||||||
| 		function (isMember, next) { | 			text: pluginId, | ||||||
| 			active = isMember; | 		}); | ||||||
|  |  | ||||||
| 			if (isMember) { | 		if (isActive) { | ||||||
| 				db.sortedSetRemove('plugins:active', pluginId, next); |  | ||||||
| 			} else { |  | ||||||
| 				next(); |  | ||||||
| 			} |  | ||||||
| 		}, |  | ||||||
| 		function (next) { |  | ||||||
| 			events.log({ |  | ||||||
| 				type: 'plugin-deactivate', |  | ||||||
| 				text: pluginId, |  | ||||||
| 			}, next); |  | ||||||
| 		}, |  | ||||||
| 	], function (err) { |  | ||||||
| 		if (err) { |  | ||||||
| 			winston.error('[reset] Could not disable plugin: ' + pluginId + ' encountered error %s', err); |  | ||||||
| 		} else if (active) { |  | ||||||
| 			winston.info('[reset] Plugin `%s` disabled', pluginId); | 			winston.info('[reset] Plugin `%s` disabled', pluginId); | ||||||
| 		} else { | 		} else { | ||||||
| 			winston.warn('[reset] Plugin `%s` was not active on this forum', pluginId); | 			winston.warn('[reset] Plugin `%s` was not active on this forum', pluginId); | ||||||
| 			winston.info('[reset] No action taken.'); | 			winston.info('[reset] No action taken.'); | ||||||
| 			err = new Error('plugin-not-active'); | 			throw new Error('plugin-not-active'); | ||||||
| 		} | 		} | ||||||
|  | 	} catch (err) { | ||||||
| 		callback(err); | 		winston.error('[reset] Could not disable plugin: ' + pluginId + ' encountered error %s', err); | ||||||
| 	}); | 		throw err; | ||||||
|  | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| function resetPlugins(callback) { | async function resetPlugins() { | ||||||
| 	db.delete('plugins:active', function (err) { | 	await db.delete('plugins:active'); | ||||||
| 		winston.info('[reset] All Plugins De-activated'); | 	winston.info('[reset] All Plugins De-activated'); | ||||||
| 		callback(err); |  | ||||||
| 	}); |  | ||||||
| } | } | ||||||
|  |  | ||||||
| function resetWidgets(callback) { | async function resetWidgets() { | ||||||
| 	async.waterfall([ | 	await plugins.reload(); | ||||||
| 		plugins.reload, | 	await widgets.reset(); | ||||||
| 		widgets.reset, | 	winston.info('[reset] All Widgets moved to Draft Zone'); | ||||||
| 		function (next) { |  | ||||||
| 			winston.info('[reset] All Widgets moved to Draft Zone'); |  | ||||||
| 			next(); |  | ||||||
| 		}, |  | ||||||
| 	], callback); |  | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user