Beispiel #1
0
 /**
  * Main method.
  *
  * @return int
  */
 function main()
 {
     $format = 0;
     while (false !== ($c = $this->getOption($v))) {
         switch ($c) {
             case '__ambiguous':
                 $this->resolveOptionAmbiguity($v);
                 break;
             case 'z':
                 $format = static::FORMAT_ZIP;
                 break;
             case 'p':
                 $format = static::FORMAT_PHAR;
                 break;
             case 'h':
             case '?':
             default:
                 return $this->usage();
                 break;
         }
     }
     $archiveName = null;
     $finder = new Finder();
     $finder->files()->in(SABRE_KATANA_PREFIX)->notIn('/^\\.git$/');
     if (0 === $format) {
         return $this->usage();
     } elseif (static::FORMAT_ZIP === $format) {
         $pathName = 'katana.zip';
         $finder->notIn('/^' . preg_quote($pathName, '/') . '$/');
         $archiveName = $pharPathname = SABRE_KATANA_PREFIX . '/data/share/' . $pathName;
         if (true === file_exists($pharPathname)) {
             unlink($pharPathname);
         }
         $zip = new Zip($pharPathname);
         $zip->buildFromIterator($finder, SABRE_KATANA_PREFIX);
     } elseif (static::FORMAT_PHAR === $format) {
         if (false === Phar::canWrite()) {
             throw new Exception\Console('Cannot create the PHAR. ' . 'Retry with `php -d phar.readonly=0 ' . $_SERVER['argv'][0] . ' stub --phar');
         }
         $pathName = 'katana.phar';
         $finder->notIn('/^' . preg_quote($pathName, '/') . '$/');
         $archiveName = $pharPathname = SABRE_KATANA_PREFIX . '/data/share/';
         if (true === file_exists($pharPathname)) {
             unlink($pharPathname);
         }
         $phar = new Phar($pharPathname);
         $phar->buildFromIterator($finder, SABRE_KATANA_PREFIX);
         $phar->setStub($phar->getStubCode());
     }
     echo $archiveName, "\n";
 }
Beispiel #2
0
 function case_format()
 {
     $this->when($zip = new CUT($this->helper->temporaryFile('.zip')))->then->boolean($zip->isFileFormat(PHPPhar::ZIP))->isTrue();
 }