Fix circular dependencies in migrator
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
23
src/cli/decorators.ts
Normal file
23
src/cli/decorators.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import {ContainerBlueprint, Instantiable, isInstantiableOf} from '../di'
|
||||
import {CommandLine} from './service'
|
||||
import {Directive} from './Directive'
|
||||
import {logIfDebugging} from '../util'
|
||||
|
||||
/**
|
||||
* Register a class as a command-line Directive.
|
||||
* The class must extend Directive.
|
||||
* @constructor
|
||||
*/
|
||||
export const CLIDirective = (): ClassDecorator => {
|
||||
return (target) => {
|
||||
if ( isInstantiableOf(target, Directive) ) {
|
||||
logIfDebugging('extollo.cli.decorators', 'Registering CLIDirective blueprint:', target)
|
||||
ContainerBlueprint.getContainerBlueprint()
|
||||
.onResolve<CommandLine>(CommandLine, cli => {
|
||||
cli.registerDirective(target as Instantiable<Directive>)
|
||||
})
|
||||
} else {
|
||||
logIfDebugging('extollo.cli.decorators', 'Skipping CLIDirective blueprint:', target)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user