InitDependence.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace App\Console\Commands;
  3. use App\Tools\Tools;
  4. use Illuminate\Console\Command;
  5. use Symfony\Component\Process\Exception\ProcessFailedException;
  6. use Symfony\Component\Process\Process;
  7. class InitDependence extends Command
  8. {
  9. /**
  10. * The name and signature of the console command.
  11. *
  12. * @var string
  13. */
  14. protected $signature = 'init:dep';
  15. /**
  16. * The console command description.
  17. *
  18. * @var string
  19. */
  20. protected $description = 'init dependence date - pali sencence ect.';
  21. /**
  22. * Create a new command instance.
  23. *
  24. * @return void
  25. */
  26. public function __construct()
  27. {
  28. parent::__construct();
  29. }
  30. /**
  31. * Execute the console command.
  32. *
  33. * @return int
  34. */
  35. public function handle()
  36. {
  37. if (Tools::isStop()) {
  38. return 0;
  39. }
  40. // 克隆依赖的数据仓库到本地
  41. $depDir = $this->info(config('mint.path.dependence'));
  42. foreach ($this->info(config('mint.dependence')) as $key => $value) {
  43. // code...
  44. $process = new Process(['git', 'clone', $value->url, $depDir.'/'.$value->path]);
  45. $process->run();
  46. if (! $process->isSuccessful()) {
  47. throw new ProcessFailedException($process);
  48. }
  49. $this->info($process->getOutput());
  50. }
  51. return 0;
  52. }
  53. }