Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
uyab committed Jun 12, 2016
1 parent 32703c7 commit c3c4a1e
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 2 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 5 additions & 1 deletion src/PackerHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
5 changes: 4 additions & 1 deletion src/PackerNewCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit c3c4a1e

Please sign in to comment.