Skip to content

Commit

Permalink
Fix publish command mangling .env file (#928)
Browse files Browse the repository at this point in the history
Co-authored-by: Michi Hoffmann <cleptric@users.noreply.github.com>
  • Loading branch information
stayallive and cleptric authored Jul 19, 2024
1 parent 75137a9 commit c37336f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Sentry/Laravel/Console/PublishCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private function setEnvValues(array $values): bool
if (count($values) > 0) {
foreach ($values as $envKey => $envValue) {
if ($this->isEnvKeySet($envKey, $envFileContents)) {
$envFileContents = preg_replace("/^{$envKey}=.*?[\s$]/m", "{$envKey}={$envValue}\n", $envFileContents);
$envFileContents = preg_replace("/^{$envKey}=\"?.*?\"?(\s|$)/m", "{$envKey}={$envValue}\n", $envFileContents);

$this->info("Updated {$envKey} with new value in your `.env` file.");
} else {
Expand All @@ -131,7 +131,7 @@ private function isEnvKeySet(string $envKey, ?string $envFileContents = null): b
{
$envFileContents = $envFileContents ?? file_get_contents(app()->environmentFilePath());

return (bool)preg_match("/^{$envKey}=.*?[\s$]/m", $envFileContents);
return (bool)preg_match("/^{$envKey}=\"?.*?\"?(\s|$)/m", $envFileContents);
}

private function askForDsnInput(): string
Expand Down

0 comments on commit c37336f

Please sign in to comment.