Skip to content

Commit 93247f9

Browse files
authored
Ensure there is a newline before writing env variables (#1002)
1 parent 42d03af commit 93247f9

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Sentry/Laravel/Console/PublishCommand.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ private function setEnvValues(array $values): bool
105105

106106
$this->info("Updated {$envKey} with new value in your `.env` file.");
107107
} else {
108+
// Ensure there is a newline before writing env variables
109+
if (substr($envFileContents, -1) !== "\n") {
110+
$envFileContents .= "\n";
111+
}
108112
$envFileContents .= "{$envKey}={$envValue}\n";
109113

110114
$this->info("Added {$envKey} to your `.env` file.");

0 commit comments

Comments
 (0)