2020-09-22 10:42:39 +00:00
|
|
|
import { plugin, task } from '@ccms/api'
|
2020-09-24 10:36:10 +00:00
|
|
|
import { provideSingleton, Autowired } from '@ccms/container'
|
2020-09-22 10:42:39 +00:00
|
|
|
|
|
|
|
@provideSingleton(PluginTaskManager)
|
|
|
|
export class PluginTaskManager {
|
2020-09-24 10:36:10 +00:00
|
|
|
@Autowired()
|
2020-09-22 10:42:39 +00:00
|
|
|
private taskManager: task.TaskManager
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
process.on('plugin.after.disable', (plugin: plugin.Plugin) => this.cancelTask(plugin))
|
|
|
|
}
|
|
|
|
|
|
|
|
private cancelTask(pluginInstance: plugin.Plugin) {
|
|
|
|
this.taskManager.disable(pluginInstance)
|
|
|
|
}
|
|
|
|
}
|