diff --git a/lib/Cake/Console/Command/Task/ProjectTask.php b/lib/Cake/Console/Command/Task/ProjectTask.php
index d54c92831..a3865b06d 100644
--- a/lib/Cake/Console/Command/Task/ProjectTask.php
+++ b/lib/Cake/Console/Command/Task/ProjectTask.php
@@ -49,23 +49,21 @@ class ProjectTask extends Shell {
$project = $this->args[0];
}
- if ($project && isset($_SERVER['PWD'])) {
- $project = $_SERVER['PWD'] . DS . $project;
- }
-
while (!$project) {
$prompt = __d('cake_console', "What is the path to the project you want to bake?");
$project = $this->in($prompt, null, APP_PATH . 'myapp');
}
- if ($project) {
- $response = false;
- while ($response == false && is_dir($project) === true && file_exists($project . 'Config' . 'core.php')) {
- $prompt = __d('cake_console', 'A project already exists in this location: %s Overwrite?', $project);
- $response = $this->in($prompt, array('y','n'), 'n');
- if (strtolower($response) === 'n') {
- $response = $project = false;
- }
+ if ($project && !Folder::isAbsolute($project) && isset($_SERVER['PWD'])) {
+ $project = $_SERVER['PWD'] . DS . $project;
+ }
+
+ $response = false;
+ while ($response == false && is_dir($project) === true && file_exists($project . 'Config' . 'core.php')) {
+ $prompt = __d('cake_console', 'A project already exists in this location: %s Overwrite?', $project);
+ $response = $this->in($prompt, array('y','n'), 'n');
+ if (strtolower($response) === 'n') {
+ $response = $project = false;
}
}
diff --git a/lib/Cake/Test/Case/Console/Command/Task/ProjectTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/ProjectTaskTest.php
index 8d0bd27de..bf130e6c9 100644
--- a/lib/Cake/Test/Case/Console/Command/Task/ProjectTaskTest.php
+++ b/lib/Cake/Test/Case/Console/Command/Task/ProjectTaskTest.php
@@ -109,6 +109,20 @@ class ProjectTaskTest extends CakeTestCase {
}
}
+/**
+ * test bake with an absolute path.
+ *
+ * @return void
+ */
+ public function testExecuteWithAbsolutePath() {
+ $this->Task->args[0] = TMP . 'tests' . DS . 'bake_test';
+ $this->Task->params['skel'] = CAKE . 'Console' . DS . 'templates' . DS . 'skel';
+ $this->Task->expects($this->at(0))->method('in')->will($this->returnValue('y'));
+ $this->Task->execute();
+
+ $this->assertTrue(is_dir($this->Task->args[0]), 'No project dir');
+ }
+
/**
* test bake() method with -empty flag, directory creation and empty files.
*