Skip to content

Commit

Permalink
fixes #6467, cake bake on windows drive. thanks burzum
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8257 3807eeeb-6ff5-0310-8944-8be069107fe0
  • Loading branch information
gwoo committed Jul 27, 2009
1 parent a6f25f5 commit f53181b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
14 changes: 8 additions & 6 deletions cake/console/cake.php
Expand Up @@ -446,13 +446,15 @@ function stderr($string) {
*/
function parseParams($params) {
$this->__parseParams($params);

$defaults = array('app' => 'app', 'root' => dirname(dirname(dirname(__FILE__))), 'working' => null, 'webroot' => 'webroot');

$params = array_merge($defaults, array_intersect_key($this->params, $defaults));

$isWin = array_filter(array_map('strpos', $params, array('\\')));

$isWin = false;
foreach ($defaults as $default => $value) {
if (strpos($params[$default], '\\') !== false) {
$isWin = true;
break;
}
}
$params = str_replace('\\', '/', $params);

if (!empty($params['working']) && (!isset($this->args[0]) || isset($this->args[0]) && $this->args[0]{0} !== '.')) {
Expand All @@ -464,7 +466,7 @@ function parseParams($params) {
}
}

if ($params['app'][0] == '/' || preg_match('/([a-zA-Z])(:)/i', $params['app'], $matches)) {
if ($params['app'][0] == '/' || preg_match('/([a-z])(:)/i', $params['app'], $matches)) {
$params['root'] = dirname($params['app']);
} elseif (strpos($params['app'], '/')) {
$params['root'] .= '/' . dirname($params['app']);
Expand Down
19 changes: 19 additions & 0 deletions cake/tests/cases/console/cake.test.php
Expand Up @@ -396,6 +396,25 @@ function testParseParams() {
$Dispatcher->params = $Dispatcher->args = array();
$Dispatcher->parseParams($params);
$this->assertEqual($expected, $Dispatcher->params);


$params = array(
'cake.php',
'-working',
'D:\www',
'bake',
'my_app',
);
$expected = array(
'working' => 'D:\www',
'app' => 'www',
'root' => 'D:',
'webroot' => 'webroot'
);

$Dispatcher->params = $Dispatcher->args = array();
$Dispatcher->parseParams($params);
$this->assertEqual($expected, $Dispatcher->params);
}
/**
* testBuildPaths method
Expand Down

0 comments on commit f53181b

Please sign in to comment.