Import other modules into monorepo
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:
31
src/cli/directive/RunDirective.ts
Normal file
31
src/cli/directive/RunDirective.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import {Directive} from "../Directive"
|
||||
import {CommandLineApplication} from "../service"
|
||||
import {Injectable} from "../../di"
|
||||
import {ErrorWithContext} from "../../util"
|
||||
import {Unit} from "../../lifecycle/Unit";
|
||||
|
||||
/**
|
||||
* A directive that starts the framework's final target normally.
|
||||
* In most cases, this runs the HTTP server, which would have been replaced
|
||||
* by the CommandLineApplication unit.
|
||||
*/
|
||||
@Injectable()
|
||||
export class RunDirective extends Directive {
|
||||
getDescription(): string {
|
||||
return 'run the application normally'
|
||||
}
|
||||
|
||||
getKeywords(): string | string[] {
|
||||
return ['run', 'up']
|
||||
}
|
||||
|
||||
async handle(): Promise<void> {
|
||||
if ( !CommandLineApplication.getReplacement() ) {
|
||||
throw new ErrorWithContext(`Cannot run application: no run target specified.`)
|
||||
}
|
||||
|
||||
const unit = <Unit> this.make(CommandLineApplication.getReplacement())
|
||||
await this.app().startUnit(unit)
|
||||
await this.app().stopUnit(unit)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user