Skip to content

Commit 0dffddd

Browse files
Merge remote-tracking branch 'pr-set-empty-values/update-empty-variable'
2 parents dd17003 + fbe6e96 commit 0dffddd

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/EnvironmentSetCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ public function handle()
4949
$contents = file_get_contents($envFilePath);
5050

5151
if ($oldValue = $this->getOldValue($contents, $key)) {
52-
$contents = str_replace("{$key}={$oldValue}", "{$key}={$value}", $contents);
52+
$contents = str_replace("{$oldValue}", "{$key}={$value}", $contents);
5353
$this->writeFile($envFilePath, $contents);
5454

55-
return $this->info("Environment variable with key '{$key}' has been changed from '{$oldValue}' to '{$value}'");
55+
return $this->info("Environment variable with key '{$key}' has been updated to '{$value}'");
5656
}
5757

5858
$contents = $contents . "\n{$key}={$value}\n";
@@ -89,7 +89,7 @@ protected function getOldValue(string $envFile, string $key): string
8989
preg_match("/^{$key}=[^\r\n]*/m", $envFile, $matches);
9090

9191
if (count($matches)) {
92-
return substr($matches[0], strlen($key) + 1);
92+
return $matches[0];
9393
}
9494

9595
return '';

0 commit comments

Comments
 (0)