Skip to content

Commit

Permalink
ACMS-1900: Supporting environment variable with NO value.
Browse files Browse the repository at this point in the history
  • Loading branch information
apathak18 committed Sep 19, 2023
1 parent 44fbd56 commit 157fab2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/Helpers/InstallerQuestions.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ public function getDefaultValue(array $question, string $key = ""): string {
* Returns the default value for question.
*/
public function getEnvValue(array $question, string $key = ""): string {
return trim(PHPParser::parseEnvVars(!empty(getenv($key)) ? getenv($key) : ''));
$env = getenv(str_replace("-", "_", strtoupper($key)));
return trim(PHPParser::parseEnvVars(!empty($env) ? $env : ''));
}

/**
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/Helpers/InstallerQuestionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,15 +220,15 @@ public function providerDefaultValue(): array {
'some_value',
'sitestudio-api-key',
[
'sitestudio-api-key' => 'some_value',
'SITESTUDIO_API_KEY' => 'some_value',
],
],
[
CliTest::getGmapsKey()['gmaps-key'],
'',
'some_value',
'gmaps-key',
[
'SOME_RANDOM_VALUE' => 'some_value',
'GMAPS_KEY' => 'some_value',
],
],
];
Expand Down

0 comments on commit 157fab2

Please sign in to comment.