Skip to content

Commit

Permalink
Remove empty files after bake
Browse files Browse the repository at this point in the history
  • Loading branch information
bcrowe committed Sep 23, 2014
1 parent 14f1319 commit fa495a6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Shell/Task/ModelTask.php
Expand Up @@ -17,6 +17,7 @@
use Cake\Console\Shell;
use Cake\Core\Configure;
use Cake\Datasource\ConnectionManager;
use Cake\Filesystem\File;
use Cake\ORM\Table;
use Cake\ORM\TableRegistry;
use Cake\Utility\Inflector;
Expand Down Expand Up @@ -602,6 +603,10 @@ public function bakeEntity($model, array $data = []) {
$filename = $path . 'Entity' . DS . $name . '.php';
$this->out("\n" . sprintf('Baking entity class for %s...', $name), 1, Shell::QUIET);
$this->createFile($filename, $out);
$emptyFile = new File($path . 'Entity' . DS . 'empty');
if ($emptyFile->exists()) {
$emptyFile->delete();
}
return $out;
}

Expand Down Expand Up @@ -645,6 +650,10 @@ public function bakeTable($model, array $data = []) {
$filename = $path . 'Table' . DS . $name . 'Table.php';
$this->out("\n" . sprintf('Baking table class for %s...', $name), 1, Shell::QUIET);
$this->createFile($filename, $out);
$emptyFile = new File($path . 'Table' . DS . 'empty');
if ($emptyFile->exists()) {
$emptyFile->delete();
}
return $out;
}

Expand Down
6 changes: 6 additions & 0 deletions src/Shell/Task/SimpleBakeTask.php
Expand Up @@ -16,6 +16,8 @@

use Cake\Shell\Task\BakeTask;
use Cake\Core\Configure;
use Cake\Core\Plugin;
use Cake\Filesystem\File;
use Cake\Utility\Inflector;

/**
Expand Down Expand Up @@ -95,6 +97,10 @@ public function bake($name) {

$filename = $this->getPath() . $this->fileName($name);
$this->createFile($filename, $contents);
$emptyFile = new File($this->getPath() . DS . 'empty');
if ($emptyFile->exists()) {
$emptyFile->delete();
}
return $contents;
}

Expand Down

0 comments on commit fa495a6

Please sign in to comment.