Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Enabling the ability for Pattern Lab to follow any symlinks that may …
…exist when scanning the pattern source directory for patterns; adds the RecursiveIteratorIterator flag to follow symbolic links while still continuing to skip dots (. and ..).

This opens the door for some creative workarounds to the rigid way Pattern Lab expects pattern templates to be organized at the file system level + how the physical path to a pattern determines how it's organized in Pattern Lab... pattern-lab#28
  • Loading branch information
bolt-bot committed Jul 1, 2017
commit 60fc319c66c28ec086799fb1b47964e0ee6a6c01
7 changes: 3 additions & 4 deletions src/PatternLab/PatternData.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,14 @@ public static function gather($options = array()) {
if (!is_dir(Config::getOption("patternSourceDir"))) {
Console::writeError("having patterns is important. please make sure you've installed a starterkit and/or that ".Console::getHumanReadablePath(Config::getOption("patternSourceDir"))." exists...");
}
$patternObjects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(Config::getOption("patternSourceDir")), \RecursiveIteratorIterator::SELF_FIRST);
$patternObjects->setFlags(\FilesystemIterator::SKIP_DOTS);

$patternSourceDir = Config::getOption("patternSourceDir");
$patternObjects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($patternSourceDir, \RecursiveDirectoryIterator::FOLLOW_SYMLINKS | \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST);

// sort the returned objects
$patternObjects = iterator_to_array($patternObjects);
ksort($patternObjects);

$patternSourceDir = Config::getOption("patternSourceDir");

foreach ($patternObjects as $name => $object) {

$ext = $object->getExtension();
Expand Down