Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async overrideStartLogic(opts: StartOptions) {
let newStartFn;
const claimed = [];
for (const plugin of this.plugins) {
if (typeof plugin.startLogic === 'function' && plugin.startLogic !== PluginBase.prototype.startLogic) {
claimed.push(plugin.name);
newStartFn = plugin.startLogic;
}
}
if (claimed.length > 1) {
throw new Error(`Multiple plugins tried to take control of the start command, please remove one of them\n --> ${claimed.join(', ')}`);
}
if (claimed.length === 1 && newStartFn) {
d(`plugin: "${claimed[0]}" has taken control of the start command`);
return newStartFn(opts);
}
return false;
}
}