Skip to content

Commit

Permalink
Merge pull request #184 from AthennaIO/develop
Browse files Browse the repository at this point in the history
Read `env` setting for commands
  • Loading branch information
jlenon7 authored Feb 21, 2024
2 parents b0b0a03 + 533068b commit 93b7065
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 80 deletions.
184 changes: 108 additions & 76 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/artisan",
"version": "4.32.0",
"version": "4.33.0",
"description": "The Athenna CLI application. Built on top of commander and inspired in @adonisjs/ace.",
"license": "MIT",
"author": "João Lenon <[email protected]>",
Expand Down Expand Up @@ -71,7 +71,7 @@
"columnify": "^1.6.0",
"commander": "^9.5.0",
"figlet": "^1.7.0",
"inquirer": "^9.2.12",
"inquirer": "^9.2.13",
"log-update": "^5.0.1",
"ora": "^6.3.1"
},
Expand Down
8 changes: 7 additions & 1 deletion src/artisan/ArtisanImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,18 @@ export class ArtisanImpl {
command = {}
}

const { loadApp, stayAlive, environments } = Options.create(command, {
const { env, loadApp, stayAlive, environments } = Options.create(command, {
env: process.env.APP_ENV || process.env.NODE_ENV,
loadApp: false,
stayAlive: false,
environments: ['console']
})

if (env) {
process.env.APP_ENV = env
process.env.NODE_ENV = env
}

if (loadApp) {
const ignite = ioc.safeUse('Athenna/Core/Ignite')

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/artisan/ArtisanTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default class ArtisanTest extends BaseTest {
})
.argument('<hello>', 'Description for hello arg.')
.option('--hello [hello]', 'Description for hello option.')
.settings({ loadApp: true, stayAlive: false, environments: ['hello', 'world'] })
.settings({ env: 'test', loadApp: true, stayAlive: false, environments: ['hello', 'world'] })

await Artisan.parse(['node', 'artisan', 'hello', 'world', '--hello=world'])

Expand Down

0 comments on commit 93b7065

Please sign in to comment.