Olivier Massot 2 年之前
父节点
当前提交
3d6601c0ef
共有 3 个文件被更改,包括 11 次插入2 次删除
  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
     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
 ### Déboguer
 
 

+ 7 - 1
src/Commands/SetupEnvCommand.php

@@ -60,7 +60,13 @@ class SetupEnvCommand extends Command
 
 
     protected function execute(InputInterface $input, OutputInterface $output): int
     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)) {
         if (!array_key_exists($hostname, self::ENVIRONMENTS_FILES)) {
             throw new \RuntimeException("Critical : unknown environment [" . $hostname . "]");
             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');"
 php -r "unlink('composer-setup.php'); unlink('installer.sig');"
 
 
 # Install modules
 # Install modules
-php composer.phar install --no-interaction --ignore-platform-reqs
+HOST=ci php composer.phar install --no-interaction --ignore-platform-reqs