Add support for empty values in the persistEnv method

This commit is contained in:
Nico Stapelbroek 2018-11-25 16:45:49 +01:00
parent e6fc6f3970
commit 3d632a4441

View File

@ -389,11 +389,12 @@ class InstallCommand extends Command
$envKey = strtoupper($key);
$envValue = env($envKey) ?: 'null';
file_put_contents($path, str_replace(
"{$envKey}={$envValue}",
"{$envKey}={$value}",
file_get_contents($path)
));
$envFileContents = file_get_contents($path);
$envFileContents = str_replace("{$envKey}={$envValue}", "{$envKey}={$value}", $envFileContents, $count);
if ($count < 1 && $envValue === 'null') {
$envFileContents = str_replace("{$envKey}=", "{$envKey}={$value}", $envFileContents);
}
file_put_contents($path, $envFileContents);
} catch (InvalidPathException $e) {
throw $e;
}