Browse Source

* method to gather if this session is 'interactive' or 'non interactive'

till 13 years ago
parent
commit
3f665e8bbb

+ 22 - 0
src/Composer/Repository/Vcs/SvnDriver.php

@@ -242,6 +242,28 @@ class SvnDriver extends VcsDriver implements VcsDriverInterface
         );
     }
 
+    /**
+     * Determine if composer was called with --no-interaction/-n
+     * and return the option string for the command.
+     *
+     * @return string
+     * @uses   parent::$io
+     * @see    IOInterface::isInteractive()
+     */
+    public function getSvnInteractiveSetting()
+    {
+        static $option;
+        if ($option !== null) {
+            return $option;
+        }
+        if ($this->io->isInteractive() === false) {
+            $option = '--non-interactive ';
+        } else {
+            $option = '';
+        }
+        return $option;
+    }
+
     /**
      * {@inheritDoc}
      */

+ 6 - 0
tests/Composer/Test/Repository/Vcs/SvnDriverTest.php

@@ -44,4 +44,10 @@ class SvnDriverTest extends \PHPUnit_Framework_TestCase
 
         $this->assertEquals($expect, $svn->getSvnCredentialString());
     }
+
+    public function testInteractiveString()
+    {
+        $io  = new \Composer\IO\NullIO; // non-interactive by design
+        $svn = new SvnDriver('http://svn.example.org', $io);
+    }
 }