$source = $this->extract($source);
$this->cleanup[] = new Task\Cleanup($source);
- if ($this->args->pecl) {
+ if (!$this->args->git) {
$source = (new Task\PeclFixup($source))->run($this->verbosity());
}
}
$this->source = new SourceDir\Git($source);
} elseif (is_file("$source/parext_package.php")) {
$this->source = include "$source/pharext_package.php";
+ } else {
+ $this->source = new SourceDir\Basic($source);
}
if (!$this->source instanceof SourceDir) {
--- /dev/null
+<?php
+
+namespace pharext\SourceDir;
+
+use pharext\Cli\Args;
+use pharext\SourceDir;
+
+use FilesystemIterator;
+use IteratorAggregate;
+use RecursiveDirectoryIterator;
+use RecursiveIteratorIterator;
+
+
+class Basic implements IteratorAggregate, SourceDir
+{
+ private $path;
+
+ public function __construct($path) {
+ $this->path = $path;
+ }
+
+ public function getBaseDir() {
+ return $this->path;
+ }
+
+ public function getPackageInfo() {
+ return [];
+ }
+
+ public function getArgs() {
+ return [];
+ }
+
+ public function setArgs(Args $args) {
+ }
+
+ public function getIterator() {
+ $rdi = new RecursiveDirectoryIterator($this->path,
+ FilesystemIterator::CURRENT_AS_SELF | // needed for 5.5
+ FilesystemIterator::KEY_AS_PATHNAME |
+ FilesystemIterator::SKIP_DOTS);
+ $rii = new RecursiveIteratorIterator($rdi,
+ RecursiveIteratorIterator::CHILD_FIRST);
+ return $rii;
+ foreach ($rii as $path => $child) {
+ if (!$child->isDir()) {
+ #yield $path;
+ }
+ }
+ }
+}
}
$dirs = glob("{$this->source}/*", GLOB_ONLYDIR);
$files = array_diff(glob("{$this->source}/*"), $dirs);
+ $check = array_reduce($files, function($r, $v) {
+ return $v && fnmatch("package*.xml", basename($v));
+ }, true);
- if (count($dirs) !== 1 || !count($files)) {
+ if (count($dirs) !== 1 || !$check) {
throw new Exception("Does not look like an extracted PECL dir: {$this->source}");
}