Skip to content

Commit 4e11b40

Browse files
Merge branch 'feature/historic-values'
2 parents 52f0657 + 1a1ea53 commit 4e11b40

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

composer.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
}
2121
],
2222
"require": {
23-
"php": "^7.1",
24-
"nesbot/carbon": "^2.0"
23+
"php": "^7.1"
2524
},
2625
"autoload": {
2726
"psr-4": {

src/EnvironmentSetCommand.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ public function handle()
4949
$contents = file_get_contents($envFilePath);
5050

5151
if ($oldValue = $this->getOldValue($contents, $key)) {
52-
// Comment out previous value and insert new line underneath - preg_replace to get the "active" key not commented keys
53-
$date = \Carbon\Carbon::now()->toDateTimeString();
54-
$replace = "#{$key}={$oldValue} # Edited: {$date}\n{$key}={$value}";
52+
53+
// Check if history is enabled, if so Comment out previous value and insert new line underneath
54+
$date = new Date('y-m-d H:i:s');
55+
$replace = env('ENVSET_HISTORY', false) ? "#{$key}={$oldValue} # Edited: {$date}\n{$key}={$value}" : "{$key}={$value}";
5556
$contents = preg_replace("/^{$key}={$oldValue}[^\r\n]*/m", $replace, $contents);
5657

5758
// Store changes

0 commit comments

Comments
 (0)