1 <?php
2
3 4 5 6 7 8 9 10
11
12 namespace Brickrouge;
13
14 function strip($str)
15 {
16 $parts = preg_split('#//<(/?brickrouge)>#', $str, -1, PREG_SPLIT_DELIM_CAPTURE);
17
18
19
20
21
22
23 $content = '';
24
25 foreach ($parts as $i => $part)
26 {
27 if ($i % 4 != 2)
28 {
29 continue;
30 }
31
32 $content .= $part;
33 }
34
35 return $content;
36 }
37
38 $path = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR;
39 $tmp_path = $_SERVER['argv'][1];
40
41 $iterator = new \DirectoryIterator($path);
42 $filter = new \RegexIterator($iterator, '#\.less$#');
43
44 $except = array('brickrouge.less', 'mixins.less', 'variables.less');
45
46 foreach ($filter as $file)
47 {
48 $filename = $file->getFilename();
49 $pathname = $file->getPathname();
50
51 if (in_array($filename, $except))
52 {
53 copy($pathname, $tmp_path . $filename);
54 }
55 else
56 {
57 $content = file_get_contents($pathname);
58 $content = strip($content);
59
60 file_put_contents($tmp_path . $filename, $content);
61 }
62 }