Olivier Massot há 2 anos atrás
pai
commit
3d6601c0ef
3 ficheiros alterados com 11 adições e 2 exclusões
  1. 3 0
      doc/env.md
  2. 7 1
      src/Commands/SetupEnvCommand.php
  3. 1 1
      tests/ci_docker_install.sh

+ 3 - 0
doc/env.md

@@ -31,6 +31,9 @@ On peut forcer un nom d'hôte avec l'option `--host`. Ex :
 
     bin/console ot:setup:env --host=ci
 
+Ou en définissant une variable d'environnement `HOST` :
+
+    HOST=ci bin/console ot:setup:env
 
 ### Déboguer
 

+ 7 - 1
src/Commands/SetupEnvCommand.php

@@ -60,7 +60,13 @@ class SetupEnvCommand extends Command
 
     protected function execute(InputInterface $input, OutputInterface $output): int
     {
-        $hostname = $input->getOption('host') ?? gethostname();
+        if ($input->getOption('host')) {
+            $hostname = $input->getOption('host');
+        } else if (getenv('HOST')) {
+            $hostname = getenv('HOST');
+        } else {
+            $hostname = gethostname();
+        }
 
         if (!array_key_exists($hostname, self::ENVIRONMENTS_FILES)) {
             throw new \RuntimeException("Critical : unknown environment [" . $hostname . "]");

+ 1 - 1
tests/ci_docker_install.sh

@@ -58,4 +58,4 @@ php composer-setup.php
 php -r "unlink('composer-setup.php'); unlink('installer.sig');"
 
 # Install modules
-php composer.phar install --no-interaction --ignore-platform-reqs
+HOST=ci php composer.phar install --no-interaction --ignore-platform-reqs