More verbose output for archive and git downloader

main
Jordi Boggiano 12 years ago
parent 9ed06f8853
commit b5d235abb6

@ -32,11 +32,15 @@ abstract class ArchiveDownloader extends FileDownloader
parent::download($package, $path);
$fileName = $this->getFileName($package, $path);
$this->io->write(' Unpacking archive');
if ($this->io->isVerbose()) {
$this->io->write(' Unpacking archive');
}
try {
$this->extract($fileName, $path);
$this->io->write(' Cleaning up');
if ($this->io->isVerbose()) {
$this->io->write(' Cleaning up');
}
unlink($fileName);
// If we have only a one dir inside it suppose to be a package itself

@ -80,12 +80,14 @@ class GitDownloader extends VcsDownloader
*/
protected function runCommand($commandCallable, $url, $path = null)
{
$handler = array($this, 'outputHandler');
// github, autoswitch protocols
if (preg_match('{^(?:https?|git)(://github.com/.*)}', $url, $match)) {
$protocols = array('git', 'https', 'http');
foreach ($protocols as $protocol) {
$url = escapeshellarg($protocol . $match[1]);
if (0 === $this->process->execute(call_user_func($commandCallable, $url), $ignoredOutput)) {
if (0 === $this->process->execute(call_user_func($commandCallable, $url), $handler)) {
return;
}
if (null !== $path) {
@ -97,11 +99,21 @@ class GitDownloader extends VcsDownloader
$url = escapeshellarg($url);
$command = call_user_func($commandCallable, $url);
if (0 !== $this->process->execute($command, $ignoredOutput)) {
if (0 !== $this->process->execute($command, $handler)) {
throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
}
}
public function outputHandler($type, $buffer)
{
if ($type !== 'out') {
return;
}
if ($this->io->isVerbose()) {
$this->io->write($buffer, false);
}
}
protected function setPushUrl(PackageInterface $package, $path)
{
// set push url for github projects

Loading…
Cancel
Save