Skip to content

Commit ac46152

Browse files
Bugfix dotenv test in laravel.php (#4082)
* Bugfix dotenv test in laravel.php The test to check if .env file is present was not checking if the dotenv variable was set and always used the default. Added getter for dotenv variable. * change current_path to release_or_current_path in dotenv description Change instructions for set dotenv to use release_or_current_path variable. * change current_path to release_or_current_path in dotenv description Change instructions for set dotenv to use release_or_current_path variable. * Revert "Merge branch 'master' into patch-1" This reverts commit df230db, reversing changes made to 8a92805.
1 parent 8bdd587 commit ac46152

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

recipe/common.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
* Path to `.env` file which will be used as environment variables for each command per `run()`.
8282
*
8383
* ```php
84-
* set('dotenv', '{{current_path}}/.env');
84+
* set('dotenv', '{{release_or_current_path}}/.env');
8585
* ```
8686
*/
8787
set('dotenv', false);

recipe/laravel.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,15 @@ function artisan($command, $options = [])
5858
return;
5959
}
6060

61+
// Get the dotenv path or use default.
62+
$dotenv = get('dotenv', '{{release_or_current_path}}/.env');
63+
6164
// Ensure we warn or fail when a command relies on the ".env" file.
62-
if (in_array('failIfNoEnv', $options) && !test('[ -s {{release_or_current_path}}/.env ]')) {
65+
if (in_array('failIfNoEnv', $options) && !test("[ -s $dotenv ]")) {
6366
throw new \Exception('Your .env file is empty! Cannot proceed.');
6467
}
6568

66-
if (in_array('skipIfNoEnv', $options) && !test('[ -s {{release_or_current_path}}/.env ]')) {
69+
if (in_array('skipIfNoEnv', $options) && !test("[ -s $dotenv ]")) {
6770
warning("Your .env file is empty! Skipping...</>");
6871
return;
6972
}

0 commit comments

Comments
 (0)