Skip to content

Commit c37336f

Browse files
stayallivecleptric
andauthored
Fix publish command mangling .env file (#928)
Co-authored-by: Michi Hoffmann <cleptric@users.noreply.github.com>
1 parent 75137a9 commit c37336f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Sentry/Laravel/Console/PublishCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ private function setEnvValues(array $values): bool
107107
if (count($values) > 0) {
108108
foreach ($values as $envKey => $envValue) {
109109
if ($this->isEnvKeySet($envKey, $envFileContents)) {
110-
$envFileContents = preg_replace("/^{$envKey}=.*?[\s$]/m", "{$envKey}={$envValue}\n", $envFileContents);
110+
$envFileContents = preg_replace("/^{$envKey}=\"?.*?\"?(\s|$)/m", "{$envKey}={$envValue}\n", $envFileContents);
111111

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

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

137137
private function askForDsnInput(): string

0 commit comments

Comments
 (0)