new command: start-plugin, stop-plugin, restart-plugin
Massimo Melina committed
Jun 3, 2023 at 10:30 UTC
191f1ef6f53a0788f292405d58080e73b970892b
2 files changed
+13
src/commands.ts
+12
@@ -8,6 +8,7 @@ import { openAdmin } from './listen'
8
import yaml from 'yaml'
9
import { argv, BUILD_TIMESTAMP, VERSION } from './const'
10
import { createInterface } from 'readline'
11
+import { enablePlugin } from './plugins'
12
13
if (!argv.updating)
14
try {
@@ -122,4 +123,15 @@ const commands = {
123
console.log(BUILD_TIMESTAMP)
124
}
125
},
126
+ 'start-plugin': {
127
+ params: '<name>',
128
+ async cb(name: string) {
129
+ await enablePlugin(name, false)
130
+ await enablePlugin(name)
131
+ }
132
+ },
133
+ 'stop-plugin': {
134
+ params: '<name>',
135
+ cb: (name: string) => enablePlugin(name, false),
136
+ },
137
}
src/plugins.ts
+1
@@ -45,6 +45,7 @@ export function isPluginEnabled(id: string) {
45
}
46
47
export async function enablePlugin(id: string, state=true) {
48
+ console.log("switching plugin", id, state ? "on" : "off")
49
enablePlugins.set( arr =>
50
arr.includes(id) === state ? arr
51
: state ? [...arr, id]