Skip to content

Commit

Permalink
up: allow limit load os env for action
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Apr 22, 2021
1 parent 41206a6 commit e4774d1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/Console/Controller/GitHubController.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected static function commandAliases(): array

protected function beforeExecute(): bool
{
AppHelper::loadOsEnvInfo($this->app);
// AppHelper::loadOsEnvInfo($this->app);

return true;
}
Expand Down
11 changes: 10 additions & 1 deletion app/Console/Controller/GitUseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use PhpGit\Repo;
use function array_keys;
use function implode;
use function in_array;
use function sprintf;
use function strlen;
use function strpos;
Expand Down Expand Up @@ -79,7 +80,15 @@ protected static function commandAliases(): array
*/
protected function beforeExecute(): bool
{
AppHelper::loadOsEnvInfo($this->app);
// \ddump($this);
if ($this->app) {
$groupSettings = $this->app->getParam('git', []);
$proxyActions = $groupSettings['loadEnvOn'] ?? [];

if ($proxyActions && in_array($this->getAction(), $proxyActions, true)) {
AppHelper::loadOsEnvInfo($this->app);
}
}

return true;
}
Expand Down
9 changes: 6 additions & 3 deletions app/Helper/AppHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Inhere\Kite\Helper;

use Inhere\Console\Util\Show;
use Inhere\Console\Application;
use Inhere\Console\Util\Show;
use Toolkit\Sys\Sys;
use function explode;
use function getenv;
Expand Down Expand Up @@ -71,7 +71,7 @@ public static function getLangFromENV(string $default = ''): string

// zh_CN.UTF-8
if (strpos($value, '.') > 0) {
[$value, ] = explode('.', $value);
[$value,] = explode('.', $value);

return self::LANG_MAP[$value] ?? $value;
}
Expand Down Expand Up @@ -120,7 +120,10 @@ public static function loadOsEnvInfo(Application $app): void
return;
}

Show::aList($osEnv, 'Put ENV From Config: "osEnv"', ['ucFirst' => false]);
Show::aList($osEnv, 'Put ENV From Config: "osEnv"', [
'ucFirst' => false,
'ucTitleWords' => false,
]);
// Sys::setOSEnv() TODO
foreach ($osEnv as $name => $value) {
putenv("$name=$value");
Expand Down

0 comments on commit e4774d1

Please sign in to comment.