20 lines
469 B
TypeScript
20 lines
469 B
TypeScript
import 'reflect-metadata';
|
|
|
|
/**
|
|
* Automatically execute method on plugin initialization
|
|
*/
|
|
export function Auto() {
|
|
return (
|
|
target: any,
|
|
propertyKey: string,
|
|
descriptor: PropertyDescriptor,
|
|
) => {
|
|
let autorunners: Array<string> = Reflect.getMetadata('sb:autorunners', target);
|
|
if (!autorunners) {
|
|
Reflect.defineMetadata('sb:autorunners', autorunners = [], target);
|
|
}
|
|
autorunners.push(propertyKey);
|
|
return descriptor;
|
|
};
|
|
}
|