Pārlūkot izejas kodu

Output VcsDownloader process commands in -vvv mode

Jordi Boggiano 12 gadi atpakaļ
vecāks
revīzija
5cdf40d165

+ 1 - 1
src/Composer/Downloader/VcsDownloader.php

@@ -33,7 +33,7 @@ abstract class VcsDownloader implements DownloaderInterface
     {
         $this->io = $io;
         $this->config = $config;
-        $this->process = $process ?: new ProcessExecutor;
+        $this->process = $process ?: new ProcessExecutor($io);
         $this->filesystem = $fs ?: new Filesystem;
     }
 

+ 12 - 0
src/Composer/Util/ProcessExecutor.php

@@ -13,6 +13,7 @@
 namespace Composer\Util;
 
 use Symfony\Component\Process\Process;
+use Composer\IO\IOInterface;
 
 /**
  * @author Robert Schönthal <seroscho@googlemail.com>
@@ -23,6 +24,12 @@ class ProcessExecutor
 
     protected $captureOutput;
     protected $errorOutput;
+    protected $io;
+
+    public function __construct(IOInterface $io = null)
+    {
+        $this->io = $io;
+    }
 
     /**
      * runs a process on the commandline
@@ -39,6 +46,11 @@ class ProcessExecutor
         $this->errorOutput = null;
         $process = new Process($command, $cwd, null, null, static::getTimeout());
 
+        if ($this->io && $this->io->isDebug()) {
+            $safeCommand = preg_replace('{(//[^:]+:)[^@]+}', '$1****', $command);
+            $this->io->write('Executing command ('.($cwd ?: 'CWD').'): '.$safeCommand);
+        }
+
         $callback = is_callable($output) ? $output : array($this, 'outputHandler');
         $process->run($callback);