Permalink
Browse files

* use PharData to create zip/tar when necessary

  • Loading branch information...
1 parent be56c69 commit 48a04523ad4a478b1820876c1271ba7662a49cc5 @till committed Jun 15, 2012
Showing with 24 additions and 0 deletions.
  1. +24 −0 src/Composer/Package/Dumper/BaseDumper.php
@@ -136,6 +136,30 @@ protected function getAndEnsureWorkDirectory(PackageInterface $package)
}
/**
+ * Package the given directory into an archive.
+ *
+ * The format is most likely \Phar::TAR or \Phar::ZIP.
+ *
+ * @param string $filename
+ * @param string $workDir
+ * @param int $format
+ *
+ * @throws \RuntimeException
+ */
+ protected function package($filename, $workDir, $format)
+ {
+ try {
+ $phar = new \PharData($filename, null, null, $format);
+ $phar->buildFromDirectory($workDir);
+ } catch (\UnexpectedValueException $e) {
+ $message = "Original PHAR exception: " . (string) $e;
+ $message .= PHP_EOL . PHP_EOL;
+ $message .= sprintf("Could not create archive '%s' from '%s'.", $filename, $workDir);
+ throw new \RuntimeException($message);
+ }
+ }
+
+ /**
* @param string $fileName
* @param string $sourceRef
* @param string $workDir

0 comments on commit 48a0452

Please sign in to comment.