From 9631d7c3fd3eaec63a71da815f9f37689ca412bc Mon Sep 17 00:00:00 2001 From: Joseph Bielawski Date: Tue, 10 Apr 2012 15:59:20 +0300 Subject: [PATCH] [ZipDownloader] If `unzip` command failed, give cleaner error. --- src/Composer/Downloader/ZipDownloader.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Composer/Downloader/ZipDownloader.php b/src/Composer/Downloader/ZipDownloader.php index d026e21d9..fac30eef2 100644 --- a/src/Composer/Downloader/ZipDownloader.php +++ b/src/Composer/Downloader/ZipDownloader.php @@ -33,15 +33,19 @@ class ZipDownloader extends ArchiveDownloader protected function extract($file, $path) { if (!class_exists('ZipArchive')) { + $error = 'You need the zip extension enabled to use the ZipDownloader'; + // try to use unzip on *nix if (!defined('PHP_WINDOWS_VERSION_BUILD')) { - $result = $this->process->execute('unzip '.escapeshellarg($file).' -d '.escapeshellarg($path), $ignoredOutput); - if (0 == $result) { + $command = 'unzip '.escapeshellarg($file).' -d '.escapeshellarg($path); + if (0 === $this->process->execute($command, $ignoredOutput)) { return; } + + $error = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput(); } - throw new \RuntimeException('You need the zip extension enabled to use the ZipDownloader'); + throw new \RuntimeException($error); } $zipArchive = new ZipArchive();