diff --git a/PHPCI/Helper/CommandExecutor.php b/PHPCI/Helper/CommandExecutor.php index a422d970..70bfcff5 100644 --- a/PHPCI/Helper/CommandExecutor.php +++ b/PHPCI/Helper/CommandExecutor.php @@ -127,7 +127,7 @@ class CommandExecutor } // Use "where" for windows and "which" for other OS - $findCmd = (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') ? 'which' : 'where'; + $findCmd = IS_WIN ? 'which' : 'where'; $findCmdResult = trim(shell_exec($findCmd . ' ' . $bin)); if (!empty($findCmdResult)) { diff --git a/PHPCI/Model/Build/RemoteGitBuild.php b/PHPCI/Model/Build/RemoteGitBuild.php index 43d1e6f7..4faf2557 100644 --- a/PHPCI/Model/Build/RemoteGitBuild.php +++ b/PHPCI/Model/Build/RemoteGitBuild.php @@ -67,7 +67,11 @@ class RemoteGitBuild extends Build $success = $builder->executeCommand('git clone -b %s %s "%s"', $this->getBranch(), $this->getCloneUrl(), $cloneTo); if (!empty($commit) && $commit != 'Manual') { - $builder->executeCommand('cd "%s" && git checkout %s', $cloneTo, $this->getCommitId()); + $cmd = 'cd "%s" && git checkout %s'; + if (IS_WIN) { + $cmd = 'cd /d "%s" && git checkout %s'; + } + $builder->executeCommand($cmd, $cloneTo, $this->getCommitId()); } return $success; @@ -97,7 +101,11 @@ class RemoteGitBuild extends Build $commit = $this->getCommitId(); if (!empty($commit) && $commit != 'Manual') { - $builder->executeCommand('cd "%s" && git checkout %s', $cloneTo, $this->getCommitId()); + $cmd = 'cd "%s" && git checkout %s'; + if (IS_WIN) { + $cmd = 'cd /d "%s" && git checkout %s'; + } + $builder->executeCommand($cmd, $cloneTo, $this->getCommitId()); } // Remove the key file: diff --git a/PHPCI/Plugin/Codeception.php b/PHPCI/Plugin/Codeception.php index bd168145..802d3540 100644 --- a/PHPCI/Plugin/Codeception.php +++ b/PHPCI/Plugin/Codeception.php @@ -70,6 +70,9 @@ class Codeception implements \PHPCI\Plugin } $cmd = 'cd "%s" && ' . $codecept . ' run -c "%s"'; + if (IS_WIN) { + $cmd = 'cd /d "%s" && ' . $codecept . ' run -c "%s"'; + } $success = $this->phpci->executeCommand($cmd, $this->phpci->buildPath, $this->phpci->buildPath . $configPath); return $success; diff --git a/PHPCI/Plugin/Composer.php b/PHPCI/Plugin/Composer.php index 0b89afe0..d40ac100 100644 --- a/PHPCI/Plugin/Composer.php +++ b/PHPCI/Plugin/Composer.php @@ -46,7 +46,7 @@ class Composer implements \PHPCI\Plugin return false; } $cmd = ''; - if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { + if (IS_WIN) { $cmd = 'php '; } $cmd .= $composerLocation . ' --no-ansi --no-interaction '; diff --git a/PHPCI/Plugin/Grunt.php b/PHPCI/Plugin/Grunt.php index 477a4849..ddbe7aa3 100644 --- a/PHPCI/Plugin/Grunt.php +++ b/PHPCI/Plugin/Grunt.php @@ -60,12 +60,19 @@ class Grunt implements \PHPCI\Plugin public function execute() { // if npm does not work, we cannot use grunt, so we return false - if (!$this->phpci->executeCommand('cd %s && npm install', $this->directory)) { + $cmd = 'cd %s && npm install'; + if (IS_WIN) { + $cmd = 'cd /d %s && npm install'; + } + if (!$this->phpci->executeCommand($cmd, $this->directory)) { return false; } // build the grunt command $cmd = 'cd %s && ' . $this->grunt; + if (IS_WIN) { + $cmd = 'cd /d %s && ' . $this->grunt; + } $cmd .= ' --no-color'; $cmd .= ' --gruntfile %s'; $cmd .= ' %s'; // the task that will be executed diff --git a/vars.php b/vars.php index 5725805e..46b88c79 100644 --- a/vars.php +++ b/vars.php @@ -25,3 +25,8 @@ if (!defined('ENABLE_SHELL_PLUGIN')) { if (!defined('PHPCI_IS_CONSOLE')) { define('PHPCI_IS_CONSOLE', false); } + +$isWin = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? true : false; +if (!defined('IS_WIN')) { + define('IS_WIN', $isWin); +}