Example #1
0
 protected function error(\Exception $e)
 {
     global $argv;
     if ($this->app->runningInConsole() && in_array('package:publish', $argv)) {
         $command = $this->container->command();
         if ($command) {
             $command->error($e->getMessage());
         }
         return;
     }
     throw $e;
 }
Example #2
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $packageName = $this->argument('package');
     $this->container = $this->getLaravel()->make('Mvalim\\PackageUtils\\Container');
     $this->container->setCommand($this);
     $package = $this->container->package($packageName);
     $resource = $this->argument('resource');
     $allPublishers = $resource ? [$package->getPublisher($resource)] : $package->getPublishers();
     foreach ($allPublishers as $key => $publisher) {
         $this->line('');
         $this->line('<fg=cyan>Publishing ' . str_plural($resource ?: $key) . ' for package ' . $packageName . '</fg=cyan>');
         try {
             $publisher->publish($this->option('force'));
         } catch (\Exception $e) {
             $this->error("\n" . $e->getMessage());
             return;
         }
     }
     $this->line('');
     $this->line("<info>Done:</info> Resource(s) from <fg=cyan>{$packageName}</fg=cyan> published");
 }