chore: application options (#375)

This commit is contained in:
ChengLei Shao 2022-05-13 11:18:36 +08:00 committed by GitHub
parent 0467093dfd
commit 2d38399766
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -178,7 +178,7 @@ export class Application<StateT = DefaultState, ContextT = DefaultContext> exten
return this.cli.parseAsync(argv); return this.cli.parseAsync(argv);
} }
async start(options?: StartOptions) { async start(options: StartOptions = {}) {
// reconnect database // reconnect database
if (this.db.closed()) { if (this.db.closed()) {
await this.db.reconnect(); await this.db.reconnect();
@ -205,7 +205,7 @@ export class Application<StateT = DefaultState, ContextT = DefaultContext> exten
return this.appManager.listen(...args); return this.appManager.listen(...args);
} }
async stop(options?: any) { async stop(options: any = {}) {
await this.emitAsync('beforeStop', this, options); await this.emitAsync('beforeStop', this, options);
try { try {
@ -235,13 +235,13 @@ export class Application<StateT = DefaultState, ContextT = DefaultContext> exten
await this.emitAsync('afterStop', this, options); await this.emitAsync('afterStop', this, options);
} }
async destroy(options?: any) { async destroy(options: any = {}) {
await this.emitAsync('beforeDestroy', this, options); await this.emitAsync('beforeDestroy', this, options);
await this.stop(options); await this.stop(options);
await this.emitAsync('afterDestroy', this, options); await this.emitAsync('afterDestroy', this, options);
} }
async install(options?: InstallOptions) { async install(options: InstallOptions = {}) {
await this.emitAsync('beforeInstall', this, options); await this.emitAsync('beforeInstall', this, options);
if (options?.clean) { if (options?.clean) {

View File

@ -58,7 +58,7 @@ export class PluginManager {
await this.app.emitAsync('afterLoadAll'); await this.app.emitAsync('afterLoadAll');
} }
async install(options?: InstallOptions) { async install(options: InstallOptions = {}) {
for (const [name, plugin] of this.plugins) { for (const [name, plugin] of this.plugins) {
await this.app.emitAsync('beforeInstallPlugin', plugin, options); await this.app.emitAsync('beforeInstallPlugin', plugin, options);
await plugin.install(options); await plugin.install(options);