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(); }
/** * @test */ public function shouldCreateBinDirectory() { Config::makeBinDirectory(); $this->assertTrue(Config::BinDirectoryExists()); }