Fixed 'cd' command for windows

This commit is contained in:
Corpsee 2014-03-13 00:37:57 +07:00
parent 39477678d2
commit 18701544a0
6 changed files with 28 additions and 5 deletions

View file

@ -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)) {

View file

@ -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:

View file

@ -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;

View file

@ -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 ';

View file

@ -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

View file

@ -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);
}