diff --git a/src/Artistan/Workbench/Commands/InstallCommand.php b/src/Artistan/Workbench/Commands/InstallCommand.php index 145c95c..3e1e018 100644 --- a/src/Artistan/Workbench/Commands/InstallCommand.php +++ b/src/Artistan/Workbench/Commands/InstallCommand.php @@ -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']); } diff --git a/src/Artistan/Workbench/Helpers/BenchHelper.php b/src/Artistan/Workbench/Helpers/BenchHelper.php index 6291298..9a3254a 100644 --- a/src/Artistan/Workbench/Helpers/BenchHelper.php +++ b/src/Artistan/Workbench/Helpers/BenchHelper.php @@ -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 ); } } @@ -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);