Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / consolidation / robo / src / Runner.php
index e1a779c35c8d8a4ffae75df4ad774794daf8b2c6..026ac871bc8c60ffb55e9e08e806abff78e9c0e2 100644 (file)
@@ -10,6 +10,7 @@ use Robo\Common\IO;
 use Robo\Exception\TaskExitException;
 use League\Container\ContainerAwareInterface;
 use League\Container\ContainerAwareTrait;
+use Consolidation\Config\Util\EnvConfig;
 
 class Runner implements ContainerAwareInterface
 {
@@ -44,6 +45,16 @@ class Runner implements ContainerAwareInterface
      */
     protected $selfUpdateRepository = null;
 
+    /**
+     * @var string filename to load configuration from (set to 'robo.yml' for RoboFiles)
+     */
+    protected $configFilename = 'conf.yml';
+
+    /**
+     * @var string prefix for environment variable configuration overrides
+     */
+    protected $envConfigPrefix = false;
+
     /**
      * @var \Composer\Autoload\ClassLoader
      */
@@ -134,6 +145,19 @@ class Runner implements ContainerAwareInterface
         return $this->run($argv, $output, $app, $commandFiles, $this->classLoader);
     }
 
+    /**
+     * Get a list of locations where config files may be loaded
+     * @return string[]
+     */
+    protected function getConfigFilePaths($userConfig)
+    {
+        $roboAppConfig = dirname(__DIR__) . '/' . basename($userConfig);
+        $configFiles = [$userConfig, $roboAppConfig];
+        if (dirname($userConfig) != '.') {
+            array_unshift($configFiles, basename($userConfig));
+        }
+        return $configFiles;
+    }
     /**
      * @param null|\Symfony\Component\Console\Input\InputInterface $input
      * @param null|\Symfony\Component\Console\Output\OutputInterface $output
@@ -160,9 +184,12 @@ class Runner implements ContainerAwareInterface
 
         // If we were not provided a container, then create one
         if (!$this->getContainer()) {
-            $userConfig = 'robo.yml';
-            $roboAppConfig = dirname(__DIR__) . '/robo.yml';
-            $config = Robo::createConfiguration([$userConfig, $roboAppConfig]);
+            $configFiles = $this->getConfigFilePaths($this->configFilename);
+            $config = Robo::createConfiguration($configFiles);
+            if ($this->envConfigPrefix) {
+                $envConfig = new EnvConfig($this->envConfigPrefix);
+                $config->addContext('env', $envConfig);
+            }
             $container = Robo::createDefaultContainer($input, $output, $app, $config, $classLoader);
             $this->setContainer($container);
             // Automatically register a shutdown function and
@@ -350,6 +377,10 @@ class Runner implements ContainerAwareInterface
      */
     protected function isShebangFile($filepath)
     {
+        // Avoid trying to call $filepath on remote URLs
+        if ((strpos($filepath, '://') !== false) && (substr($filepath, 0, 7) != 'file://')) {
+            return false;
+        }
         if (!is_file($filepath)) {
             return false;
         }
@@ -498,6 +529,28 @@ class Runner implements ContainerAwareInterface
         return $this;
     }
 
+    /**
+     * @param string $configFilename
+     *
+     * @return $this
+     */
+    public function setConfigurationFilename($configFilename)
+    {
+        $this->configFilename = $configFilename;
+        return $this;
+    }
+
+    /**
+     * @param string $envConfigPrefix
+     *
+     * @return $this
+     */
+    public function setEnvConfigPrefix($envConfigPrefix)
+    {
+        $this->envConfigPrefix = $envConfigPrefix;
+        return $this;
+    }
+
     /**
      * @param \Composer\Autoload\ClassLoader $classLoader
      *