Skip to content
This repository was archived by the owner on Feb 7, 2023. It is now read-only.

Commit e3fdb3b

Browse files
committed
smarter search for MQ options
1 parent 9813f7c commit e3fdb3b

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

core/lib/PatternLab/Builder.php

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,27 @@ protected function gatherMQs() {
4444

4545
$mqs = array();
4646

47-
foreach(glob(Config::$options["sourceDir"]."/css/*.css") as $filename) {
48-
$data = file_get_contents($filename);
49-
preg_match_all("/(min|max)-width:([ ]+)?(([0-9]{1,5})(\.[0-9]{1,20}|)(px|em))/",$data,$matches);
50-
foreach ($matches[3] as $match) {
51-
if (!in_array($match,$mqs)) {
52-
$mqs[] = $match;
47+
// iterate over all of the other files in the source directory
48+
$directoryIterator = new \RecursiveDirectoryIterator(Config::$options["sourceDir"]);
49+
$objects = new \RecursiveIteratorIterator($directoryIterator, \RecursiveIteratorIterator::SELF_FIRST);
50+
51+
// make sure dots are skipped
52+
$objects->setFlags(\FilesystemIterator::SKIP_DOTS);
53+
54+
foreach ($objects as $name => $object) {
55+
56+
if ($object->isFile() && ($object->getExtension() == "css")) {
57+
58+
$data = file_get_contents($object->getPathname());
59+
preg_match_all("/(min|max)-width:([ ]+)?(([0-9]{1,5})(\.[0-9]{1,20}|)(px|em))/",$data,$matches);
60+
foreach ($matches[3] as $match) {
61+
if (!in_array($match,$mqs)) {
62+
$mqs[] = $match;
63+
}
5364
}
54-
}
65+
66+
}
67+
5568
}
5669

5770
usort($mqs, "strnatcmp");

0 commit comments

Comments
 (0)