Skip to content

Commit

Permalink
fix: do not load container bindings when generating manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Feb 16, 2020
1 parent 87d1c46 commit 2eb4cfe
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/Ignitor/Ace/AppCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { AceRuntimeException } from './AceRuntimeException'
* the manifest file.
*/
export class AppCommands {
private bootstrapper = new Bootstrapper(this.buildRoot)
private bootstrapper = new Bootstrapper(this.buildRoot, true)

/**
* Whether or not the app was wired. App is only wired, when
Expand Down
2 changes: 1 addition & 1 deletion src/Ignitor/Ace/GenerateManifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { AceRuntimeException } from './AceRuntimeException'
* Exposes the API to generate the manifest file
*/
export class GenerateManifest {
private bootstrapper = new Bootstrapper(this.buildRoot)
private bootstrapper = new Bootstrapper(this.buildRoot, false)

/**
* Source root always points to the compiled source
Expand Down
21 changes: 16 additions & 5 deletions src/Ignitor/Bootstrapper/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ export class Bootstrapper {
*/
private providersWithShutdownHook: any[] = []

constructor (private appRoot: string) {
constructor (
private appRoot: string,
public touchContainerBindings: boolean = false,
) {
}

/**
Expand Down Expand Up @@ -124,7 +127,9 @@ export class Bootstrapper {
}
})

this.logger = this.application.container.use('Adonis/Core/Logger')
if (this.touchContainerBindings) {
this.logger = this.application.container.use('Adonis/Core/Logger')
}
return providersRefs
}

Expand Down Expand Up @@ -164,7 +169,9 @@ export class Bootstrapper {
* Executes the ready hooks on the providers
*/
public async executeReadyHooks () {
this.logger!.trace('executing ready hooks')
if (this.logger) {
this.logger!.trace('executing ready hooks')
}
await Promise.all(this.providersWithReadyHook.map((provider) => provider.ready()))
this.providersWithReadyHook = []
}
Expand All @@ -173,7 +180,9 @@ export class Bootstrapper {
* Executes the ready hooks on the providers
*/
public async executeShutdownHooks () {
this.logger!.trace('executing shutdown hooks')
if (this.logger) {
this.logger!.trace('executing shutdown hooks')
}
await Promise.all(this.providersWithShutdownHook.map((provider) => provider.shutdown()))
this.providersWithShutdownHook = []
}
Expand All @@ -182,7 +191,9 @@ export class Bootstrapper {
* Boot providers by invoking `boot` method on them
*/
public async bootProviders () {
this.logger!.trace('booting providers')
if (this.logger) {
this.logger!.trace('booting providers')
}
await this.registrar.boot()
}
}
2 changes: 1 addition & 1 deletion src/Ignitor/HttpServer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class HttpServer {
/**
* Reference to bootstrapper
*/
private bootstrapper = new Bootstrapper(this.appRoot)
private bootstrapper = new Bootstrapper(this.appRoot, true)

/**
* Reference to core http server.
Expand Down
2 changes: 1 addition & 1 deletion src/Ignitor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class Ignitor {
* the application
*/
public boostrapper () {
return new Bootstrapper(this.appRoot)
return new Bootstrapper(this.appRoot, true)
}

/**
Expand Down
1 change: 1 addition & 0 deletions test/ignitor-ace.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ test.group('Ignitor | Ace', (group) => {
'make:controller',
'make:middleware',
'make:provider',
'make:validator',
'make:view',
'make:model',
])
Expand Down

0 comments on commit 2eb4cfe

Please sign in to comment.