diff --git a/skeleton/README.md b/skeleton/README.md.stub similarity index 100% rename from skeleton/README.md rename to skeleton/README.md.stub diff --git a/skeleton/composer.json b/skeleton/composer.json.stub similarity index 100% rename from skeleton/composer.json rename to skeleton/composer.json.stub diff --git a/skeleton/config/config.php b/skeleton/config/config.php.stub similarity index 100% rename from skeleton/config/config.php rename to skeleton/config/config.php.stub diff --git a/skeleton/src/Facade.php b/skeleton/src/Facade.php.stub similarity index 100% rename from skeleton/src/Facade.php rename to skeleton/src/Facade.php.stub diff --git a/skeleton/src/ServiceProvider.php b/skeleton/src/ServiceProvider.php.stub similarity index 100% rename from skeleton/src/ServiceProvider.php rename to skeleton/src/ServiceProvider.php.stub diff --git a/src/PackerHelper.php b/src/PackerHelper.php index f8a2c44..2c48a56 100644 --- a/src/PackerHelper.php +++ b/src/PackerHelper.php @@ -58,14 +58,18 @@ public function barSetup(ProgressBar $bar) * @param mixed $search String or array to look for (the needles) * @param mixed $replace What to replace the needles for? * @param string $newFile Where to save, defaults to $oldFile + * @param boolean $deleteOldFile Whether to delete $oldFile or not * @return void */ - public function replaceAndSave($oldFile, $search, $replace, $newFile = null) + public function replaceAndSave($oldFile, $search, $replace, $newFile = null, $deleteOldFile = false) { $newFile = ($newFile === null) ? $oldFile : $newFile ; $file = $this->files->get($oldFile); $replacing = str_replace($search, $replace, $file); $this->files->put($newFile, $replacing); + + if($deleteOldFile) + $this->files->delete($oldFile); } /** diff --git a/src/PackerNewCommand.php b/src/PackerNewCommand.php index 471d9e9..bbf3183 100644 --- a/src/PackerNewCommand.php +++ b/src/PackerNewCommand.php @@ -95,7 +95,10 @@ public function handle() foreach (File::allFiles($fullPath) as $file) { $search = [':vendor_name', ':VendorName', ':package_name', ':PackageName']; $replace = [$vendor, $cVendor, $name, $cName]; - $this->helper->replaceAndSave($file, $search, $replace); + + $newfile = substr($file, 0, -5); + + $this->helper->replaceAndSave($file, $search, $replace, $newfile, $deleteOldFile = true); } $bar->advance();