diff --git a/src/Common/ExecCommand.php b/src/Common/ExecCommand.php index cba913a94..9a4937fac 100644 --- a/src/Common/ExecCommand.php +++ b/src/Common/ExecCommand.php @@ -71,6 +71,6 @@ protected function executeCommand($command) } $this->stopTimer(); - return new Result($this, $process->getExitCode(), $process->getOutput(), ['time' => $this->getExecutionTime()]); + return new Result($this, $process->getExitCode(), $process->getOutput(), ['time' => $this->getExecutionTime()]); } } \ No newline at end of file diff --git a/src/Task/Gulp/Base.php b/src/Task/Gulp/Base.php index 59b76644c..a9ff97ad2 100644 --- a/src/Task/Gulp/Base.php +++ b/src/Task/Gulp/Base.php @@ -4,6 +4,7 @@ use Robo\Task\BaseTask; use Robo\Exception\TaskException; +use Symfony\Component\Process\ProcessUtils; abstract class Base extends BaseTask { @@ -73,6 +74,6 @@ public function __construct($task, $pathToGulp = null) public function getCommand() { - return "{$this->command} " . escapeshellarg($this->task) . "{$this->arguments}"; + return "{$this->command} " . ProcessUtils::escapeArgument($this->task) . "{$this->arguments}"; } } \ No newline at end of file diff --git a/tests/unit/GulpTest.php b/tests/unit/GulpTest.php index e34065bca..60cfb3e26 100644 --- a/tests/unit/GulpTest.php +++ b/tests/unit/GulpTest.php @@ -16,42 +16,71 @@ protected function _before() 'getOutput' => new \Symfony\Component\Console\Output\NullOutput() ]); } + // tests public function testGulpRun() { - verify( - $this->taskGulpRun('default','gulp')->getCommand() - )->equals('gulp \'default\''); - - verify( - $this->taskGulpRun('another','gulp')->getCommand() - )->equals('gulp \'another\''); + $isWindows = defined('PHP_WINDOWS_VERSION_MAJOR'); + + if ($isWindows) { + verify( + $this->taskGulpRun('default','gulp')->getCommand() + )->equals('gulp "default"'); + + verify( + $this->taskGulpRun('another','gulp')->getCommand() + )->equals('gulp "another"'); + + verify( + $this->taskGulpRun('anotherWith weired!("\') Chars','gulp')->getCommand() + )->equals('gulp "anotherWith weired!(\"\') Chars"'); - verify( - $this->taskGulpRun('anotherWith wired!("\') Chars','gulp')->getCommand() - )->equals("gulp 'anotherWith wired!(\"'\\'') Chars'"); + verify( + $this->taskGulpRun('default','gulp')->silent()->getCommand() + )->equals('gulp "default" --silent'); + verify( + $this->taskGulpRun('default','gulp')->noColor()->getCommand() + )->equals('gulp "default" --no-color'); - verify( - $this->taskGulpRun('default','gulp')->silent()->getCommand() - )->equals('gulp \'default\' --silent'); + verify( + $this->taskGulpRun('default','gulp')->color()->getCommand() + )->equals('gulp "default" --color'); - verify( - $this->taskGulpRun('default','gulp')->noColor()->getCommand() - )->equals('gulp \'default\' --no-color'); + verify( + $this->taskGulpRun('default','gulp')->simple()->getCommand() + )->equals('gulp "default" --tasks-simple'); - verify( - $this->taskGulpRun('default','gulp')->color()->getCommand() - )->equals('gulp \'default\' --color'); + } else { - verify( - $this->taskGulpRun('default','gulp')->simple()->getCommand() - )->equals('gulp \'default\' --tasks-simple'); + verify( + $this->taskGulpRun('default','gulp')->getCommand() + )->equals('gulp \'default\''); + + verify( + $this->taskGulpRun('another','gulp')->getCommand() + )->equals('gulp \'another\''); + verify( + $this->taskGulpRun('anotherWith weired!("\') Chars','gulp')->getCommand() + )->equals("gulp 'anotherWith weired!(\"'\\'') Chars'"); + verify( + $this->taskGulpRun('default','gulp')->silent()->getCommand() + )->equals('gulp \'default\' --silent'); + verify( + $this->taskGulpRun('default','gulp')->noColor()->getCommand() + )->equals('gulp \'default\' --no-color'); + verify( + $this->taskGulpRun('default','gulp')->color()->getCommand() + )->equals('gulp \'default\' --color'); + verify( + $this->taskGulpRun('default','gulp')->simple()->getCommand() + )->equals('gulp \'default\' --tasks-simple'); + } } } \ No newline at end of file