/** * @param \nochso\WriteMe\Document $document * * @return \SplFileInfo */ private function findChangelog(Document $document) { $changelogName = $this->options->getValue('changelog.file'); $searchDepth = $this->options->getValue('changelog.search-depth'); $folder = dirname($document->getFilepath()); $files = new \IteratorIterator(Finder::findFiles($changelogName)->from($folder)->limitDepth($searchDepth)); $files->next(); if (!$files->valid()) { throw new \RuntimeException(sprintf("Unable to find changelog '%s' in folder '%s'", $changelogName, $folder)); } return $files->current(); }
/** * @param \nochso\WriteMe\Document $doc * * @return \Nette\Utils\Finder */ private function getFiles(Document $doc) { $findFiles = $this->options->getValue('api.file'); $fromFolders = $this->options->getValue('api.from'); $folderExclude = $this->options->getValue('api.folder-exclude'); $docPath = $doc->getFilepath(); // Make folder paths relative to the folder of the WRITEME file in case CWD differs. if ($docPath !== null) { $fromFolders = $this->makeFoldersRelativeToFile($docPath, $fromFolders); $folderExclude = $this->makeFoldersRelativeToFile($docPath, $folderExclude); } $files = Finder::findFiles($findFiles)->from($fromFolders)->exclude($folderExclude); return $files; }