public static function postInstall()
 {
     Config::makeBinDirectory();
     $loop = Factory::create();
     $file = Config::getBinFile();
     $url = 'https://yt-dl.org/downloads/latest/youtube-dl';
     $readStream = fopen($url, 'r');
     $writeStream = fopen($file, 'w');
     stream_set_blocking($readStream, 0);
     stream_set_blocking($writeStream, 0);
     $read = new Stream($readStream, $loop);
     $write = new Stream($writeStream, $loop);
     $read->on('end', function () use($file) {
         chmod($file, 0777);
         echo "Finished downloading {$file}\n";
     });
     $read->pipe($write);
     $loop->run();
 }
 public function execute()
 {
     $process = new Process(Config::getBinFile() . " {$this->option} -- {$this->link}");
     if ($this->verbose) {
         $process->run(function ($type, $buffer) {
             if (Process::ERR === $type) {
                 echo 'ERR > ' . $buffer;
             } else {
                 echo 'OUT > ' . $buffer;
             }
         });
     } else {
         $this->async ? $process->start() : $process->run();
     }
     if (!$process->isSuccessful()) {
         throw new YoutubedlException($process->getErrorOutput());
     }
     return explode("\n", trim($process->getOutput()));
 }
 public static function postInstall()
 {
     chmod(Config::getBinFile(), 0775);
 }
 /**
  * @test
  */
 public function shouldCreateBinDirectory()
 {
     Config::makeBinDirectory();
     $this->assertTrue(Config::BinDirectoryExists());
 }
 /**
  * @test
  * @depends shouldPostInstall
  */
 public function shouldPostUpdate()
 {
     Installation::postUpdate();
     $this->assertTrue(Config::binExists());
 }