Skip to content

Commit

Permalink
Merge pull request #202 from AthennaIO/develop
Browse files Browse the repository at this point in the history
feat(commands): use env flag from global
  • Loading branch information
jlenon7 authored Jan 5, 2024
2 parents 6dcadd0 + e7120c8 commit a971a7a
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 35 deletions.
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@athenna/core",
"version": "4.16.0",
"version": "4.17.0",
"description": "The plug and play Node.js framework.",
"license": "MIT",
"author": "João Lenon <[email protected]>",
Expand Down Expand Up @@ -76,7 +76,7 @@
"semver": "^7.5.4"
},
"devDependencies": {
"@athenna/artisan": "^4.21.0",
"@athenna/artisan": "^4.24.0",
"@athenna/common": "^4.24.0",
"@athenna/config": "^4.10.0",
"@athenna/http": "^4.15.0",
Expand Down
12 changes: 3 additions & 9 deletions src/commands/ReplCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ import { Module } from '@athenna/common'
import { BaseCommand, Option } from '@athenna/artisan'

export class ReplCommand extends BaseCommand {
@Option({
signature: '-e, --env <env>',
description: 'Change the environment where the application will run.',
default: ''
})
@Option({ isFromGlobal: true, signature: '--env <env>' })
public env: string

public static signature(): string {
Expand All @@ -27,10 +23,8 @@ export class ReplCommand extends BaseCommand {
}

public async handle(): Promise<void> {
if (this.env !== '') {
process.env.APP_ENV = this.env
process.env.NODE_ENV = this.env
}
process.env.APP_ENV = this.env
process.env.NODE_ENV = this.env

const entrypoint = Config.get(
'rc.commands.repl.entrypoint',
Expand Down
12 changes: 3 additions & 9 deletions src/commands/ServeCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ import { Module } from '@athenna/common'
import { BaseCommand, Option } from '@athenna/artisan'

export class ServeCommand extends BaseCommand {
@Option({
signature: '-e, --env <env>',
description: 'Change the environment where the application will run.',
default: ''
})
@Option({ isFromGlobal: true, signature: '--env <env>' })
public env: string

@Option({
Expand All @@ -36,10 +32,8 @@ export class ServeCommand extends BaseCommand {
}

public async handle(): Promise<void> {
if (this.env !== '') {
process.env.APP_ENV = this.env
process.env.NODE_ENV = this.env
}
process.env.APP_ENV = this.env
process.env.NODE_ENV = this.env

const entrypoint = Config.get(
'rc.commands.serve.entrypoint',
Expand Down
12 changes: 3 additions & 9 deletions src/commands/TestCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ import { Module } from '@athenna/common'
import { Option, BaseCommand, Commander } from '@athenna/artisan'

export class TestCommand extends BaseCommand {
@Option({
signature: '-e, --env <env>',
description: 'Change the environment where your tests wil run.',
default: 'test'
})
@Option({ signature: '--env <env>' })
public env: string

public static signature(): string {
Expand Down Expand Up @@ -47,10 +43,8 @@ export class TestCommand extends BaseCommand {
}

public async handle(): Promise<void> {
if (this.env !== '') {
process.env.APP_ENV = this.env
process.env.NODE_ENV = this.env
}
process.env.APP_ENV = this.env || 'test'
process.env.NODE_ENV = this.env || 'test'

const entrypoint = Config.get(
'rc.commands.test.entrypoint',
Expand Down
3 changes: 3 additions & 0 deletions src/ignite/Ignite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { EnvHelper, Rc } from '@athenna/config'
import { isAbsolute, resolve } from 'node:path'
import type { ReplImpl } from '#src/repl/ReplImpl'
import { Console } from '#src/applications/Console'
import { CommanderHandler } from '@athenna/artisan'
import { LoadHelper } from '#src/helpers/LoadHelper'
import { Log, LoggerProvider } from '@athenna/logger'
import { Repl as ReplApp } from '#src/applications/Repl'
Expand Down Expand Up @@ -82,6 +83,8 @@ export class Ignite {
this.registerItselfToTheContainer()
this.setApplicationSignals()

CommanderHandler.reconstruct()

return this
} catch (err) {
await this.handleError(err)
Expand Down

0 comments on commit a971a7a

Please sign in to comment.