Fix env path for windows

This commit is contained in:
René Preuß
2021-07-24 13:00:33 +02:00
parent 917af5c140
commit 26672908f1
4 changed files with 20 additions and 3 deletions

14
app/helpers.php Normal file
View File

@@ -0,0 +1,14 @@
<?php
if (!function_exists('bunny_cli_path')) {
function bunny_cli_path(): string
{
if (strncasecmp(PHP_OS, 'WIN', 3) === 0) {
$result = exec("echo %appdata%");
} else {
$result = getenv('HOME');
}
return $result . DIRECTORY_SEPARATOR . '.bunny-cli';
}
}

View File

@@ -26,7 +26,7 @@ $app = new LaravelZero\Framework\Application(
*/ */
if (!file_exists(dirname(__DIR__) . DIRECTORY_SEPARATOR . '.env')) { if (!file_exists(dirname(__DIR__) . DIRECTORY_SEPARATOR . '.env')) {
$app->useEnvironmentPath(getenv('HOME') . DIRECTORY_SEPARATOR . '.bunny-cli'); $app->useEnvironmentPath(bunny_cli_path());
} }

View File

@@ -29,7 +29,10 @@
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"App\\": "app/" "App\\": "app/"
} },
"files": [
"app/helpers.php"
]
}, },
"autoload-dev": { "autoload-dev": {
"psr-4": { "psr-4": {

View File

@@ -5,7 +5,7 @@ return [
'disks' => [ 'disks' => [
'local' => [ 'local' => [
'driver' => 'local', 'driver' => 'local',
'root' => getenv('HOME') . DIRECTORY_SEPARATOR . '.bunny-cli', 'root' => bunny_cli_path(),
], ],
], ],
]; ];