Skip to content

Commit

Permalink
destroy one at a time for dependency reasons.
Browse files Browse the repository at this point in the history
  • Loading branch information
cpeterson committed Jun 30, 2014
1 parent 34ad4c8 commit 4fb7ad2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
7 changes: 4 additions & 3 deletions src/Artistan/Workbench/Commands/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,18 @@ public function fire()
{
$this->benchhelper->chStorage();
$packages = \Config::get('workbench::packages');
$destroy = false;
if($this->option('destroy')){
if($this->confirm('Are you sure you want to remove all configured workbench packages? [yes|no]'))
{
$this->benchhelper->destroy(array_keys($packages));
$destroy=true;
}
}
foreach($packages as $name=>$package){
$this->info( "PACKAGE: $name" );
if(isset($package['git'])){
$action = $this->benchhelper->getGit($name,$package);
if($this->option('remote')){
$action = $this->benchhelper->getGit($name,$package,$destroy);
if( $this->option('remote') && !empty($package['remotes']) && is_array($package['remotes']) ){
$this->info( "remotes" );
$this->benchhelper->fetchRemotes($name,$package['remotes']);
}
Expand Down
23 changes: 11 additions & 12 deletions src/Artistan/Workbench/Helpers/BenchHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,11 @@ public function __construct(&$command){
/**
* destroys all workbench packages
*/
public function destroy($packages) {
$this->cmd->info( "removing all configured packages" );
foreach($packages as $name){
// check if exists, also do not remove artistan/workbench cause I am working on it!!!
while( is_dir( base_path().'/workbench/'.$name) && $name!='artistan/workbench' ){
$path = explode('/',$name);
$this->exec( 'rm -rf '.base_path().'/workbench/'.$path[0] );
clearstatcache ( true, base_path().'/workbench/'.$name );
}
public function destroy($name) {
// check if exists, also do not remove artistan/workbench cause I am working on it!!!
while( is_dir( base_path().'/workbench/'.$name) && $name!='artistan/workbench' ){
$this->exec( 'rm -rf '.base_path().'/workbench/'.$name );
clearstatcache ( true, base_path().'/workbench/'.$name );
}
}

Expand Down Expand Up @@ -116,11 +112,14 @@ public function bower($name='') {
/**
* @param $name
* @param array $package
* array( 'git'=>'' [,'upstream'=>''] )
* array( 'git'=>'' )
* @param $destroy
* @return string
* @throws Exception
*/
public function getGit($name,array $package) {
public function getGit($name,array $package,$destroy) {
if($destroy){
$this->destroy($name);
}
$this->cmd->info( "get git $name" );
if(!empty($package['git'])){
$this->mkdir($name);
Expand Down

0 comments on commit 4fb7ad2

Please sign in to comment.