Ship your dependencies as phars inside the phar
[pharext/pharext] / src / pharext / Packager.php
index 0b133e357909f937b75d8244f8d3899ac4df7d45..f27c38a0a8b0f7e623b71cf514dc1f9b0b6850e5 100644 (file)
@@ -64,17 +64,21 @@ class Packager implements Command
                        $this->help($prog);
                        exit;
                }
-               
-               if ($this->args["source"]) {
-                       if ($this->args["pecl"]) {
-                               $this->source = new PeclSourceDir($this, $this->args["source"]);
-                       } elseif ($this->args["git"]) {
-                               $this->source = new GitSourceDir($this, $this->args["source"]);
-                       } elseif (realpath($this->args["source"]."/pharext_package.php")) {
-                               $this->source = new PharextSourceDir($this, $this->args["source"]);
-                       } else {
-                               $this->source = new FilteredSourceDir($this, $this->args["source"]);
+
+               try {
+                       if ($this->args["source"]) {
+                               if ($this->args["pecl"]) {
+                                       $this->source = new PeclSourceDir($this, $this->args["source"]);
+                               } elseif ($this->args["git"]) {
+                                       $this->source = new GitSourceDir($this, $this->args["source"]);
+                               } elseif (realpath($this->args["source"]."/pharext_package.php")) {
+                                       $this->source = new PharextSourceDir($this, $this->args["source"]);
+                               } else {
+                                       $this->source = new FilteredSourceDir($this, $this->args["source"]);
+                               }
                        }
+               } catch (\Exception $e) {
+                       $errs[] = $e->getMessage();
                }
                
                foreach ($this->args->validate() as $error) {
@@ -88,6 +92,7 @@ class Packager implements Command
                        foreach ($errs as $err) {
                                $this->error("%s\n", $err);
                        }
+                       printf("\n");
                        if (!$this->args["quiet"]) {
                                $this->help($prog);
                        }
@@ -119,7 +124,7 @@ class Packager implements Command
        
                $this->info("Creating phar %s ...%s", $pkgtemp, $this->args->verbose ? "\n" : " ");
                try {
-                       $package = new Phar($pkgtemp, 0, "ext.phar");
+                       $package = new Phar($pkgtemp);
                        $package->startBuffering();
                        $package->buildFromIterator($this->source, $this->source->getBaseDir());
                        $package->buildFromIterator($this->bundle());