Kaynağa Gözat

Check if input is interactive

SofHad 10 yıl önce
ebeveyn
işleme
f9777bc70a
1 değiştirilmiş dosya ile 5 ekleme ve 6 silme
  1. 5 6
      src/Composer/Command/UpdateCommand.php

+ 5 - 6
src/Composer/Command/UpdateCommand.php

@@ -88,7 +88,7 @@ EOT
 
         $packages = $input->getArgument('packages');
 
-        if ($this->isInteractive($input)) {
+        if ($input->getOption('interactive')) {
             $packages = $this->getPackagesInteractively($input, $output, $composer, $packages);
         }
 
@@ -150,6 +150,10 @@ EOT
 
     private function getPackagesInteractively(InputInterface $input, OutputInterface $output, Composer $composer, $packages)
     {
+        if (!$input->isInteractive()) {
+            throw new \InvalidArgumentException('--interactive cannot be used in non-interactive terminals.');
+        }
+
         $packagesMap = $composer->getRepositoryManager()
             ->getLocalRepository()->getPackages();
 
@@ -222,9 +226,4 @@ EOT
 
         throw new \RuntimeException('Installation aborted.');
     }
-
-    private function isInteractive($input)
-    {
-        return $input->getOption('interactive');
-    }
 }