mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
feat: better output for cli plugins list, closes #8075
This commit is contained in:
@@ -92,21 +92,39 @@ function activate(plugin) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function listPlugins() {
|
async function listPlugins() {
|
||||||
async.waterfall([
|
await db.init();
|
||||||
function (next) {
|
const installed = await plugins.showInstalled();
|
||||||
db.init(next);
|
const installedList = installed.map(plugin => plugin.name);
|
||||||
},
|
const active = await db.getSortedSetRange('plugins:active', 0, -1);
|
||||||
function (next) {
|
|
||||||
db.getSortedSetRange('plugins:active', 0, -1, next);
|
// Merge the two sets, defer to plugins in `installed` if already present
|
||||||
},
|
let combined = installed.concat(active.reduce((memo, cur) => {
|
||||||
function (plugins) {
|
if (!installedList.includes(cur)) {
|
||||||
winston.info('Active plugins: \n\t - ' + plugins.join('\n\t - '));
|
memo.push({
|
||||||
process.exit();
|
id: cur,
|
||||||
},
|
active: true,
|
||||||
], function (err) {
|
installed: false,
|
||||||
throw err;
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return memo;
|
||||||
|
}, []));
|
||||||
|
|
||||||
|
// Alphabetical sort
|
||||||
|
combined = combined.sort((a, b) => (a.id > b.id ? 1 : -1));
|
||||||
|
|
||||||
|
// Pretty output
|
||||||
|
process.stdout.write('Active plugins:\n');
|
||||||
|
combined.forEach((plugin) => {
|
||||||
|
process.stdout.write('\t* ' + plugin.id + ' (');
|
||||||
|
process.stdout.write(plugin.installed ? 'installed'.green : 'not installed'.red);
|
||||||
|
process.stdout.write(', ');
|
||||||
|
process.stdout.write(plugin.active ? 'enabled'.green : 'disabled'.yellow);
|
||||||
|
process.stdout.write(')\n');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
process.exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
function listEvents(count) {
|
function listEvents(count) {
|
||||||
|
|||||||
Reference in New Issue
Block a user