Suggest current path in bake project if dir is empty

This commit is contained in:
Jelle Henkens 2012-06-02 20:10:23 +01:00
parent 8da42dfcfa
commit 0e34bd4b1d

View file

@ -47,11 +47,18 @@ class ProjectTask extends AppShell {
$project = null; $project = null;
if (isset($this->args[0])) { if (isset($this->args[0])) {
$project = $this->args[0]; $project = $this->args[0];
} else {
$appContents = array_diff(scandir(APP), array('.', '..'));
if (empty($appContents)) {
$suggestedPath = rtrim(APP, DS);
} else {
$suggestedPath = APP . 'myapp';
}
} }
while (!$project) { while (!$project) {
$prompt = __d('cake_console', "What is the path to the project you want to bake?"); $prompt = __d('cake_console', "What is the path to the project you want to bake?");
$project = $this->in($prompt, null, APP . 'myapp'); $project = $this->in($prompt, null, $suggestedPath);
} }
if ($project && !Folder::isAbsolute($project) && isset($_SERVER['PWD'])) { if ($project && !Folder::isAbsolute($project) && isset($_SERVER['PWD'])) {