function ProcessDir($dir) { global $src, $dest, $totalDirs, $totalFiles, $totalYui; if (!file_exists($dest . substr($dir, strlen($src)))) { echo 'mkdir -> ' . $dest . substr($dir, strlen($src)) . "\n"; mkdir($dest . substr($dir, strlen($src))); } $dir .= EndsWith($dir, '/') ? '*' : '/*'; foreach (glob($dir) as $file) { if (is_dir($file)) { if (EndsWith($file, '_build')) { continue; } ++$totalDirs; ProcessDir($file); } else { if (EndsWith($file, '.zScript build ip') || EndsWith($file, '.gz') || EndsWith($file, '.bz2')) { continue; } else { if (EndsWith($file, '.js') && !EndsWith($file, '.min.js') || EndsWith($file, '.css')) { echo 'YUI Compressor -> ' . $dest . substr($file, strlen($src)) . "\n"; system('java -jar yuicompressor/yuicompressor-2.4.8.jar -o ' . $dest . substr($file, strlen($src)) . ' ' . $file); ++$totalYui; } else { copy($file, $dest . substr($file, strlen($src))); } } ++$totalFiles; } } }
function ProcessDir($Dir) { msg(" Process dir : " . $Dir, 'blue'); if ($Dh = opendir($Dir)) { while (($File = readdir($Dh)) !== false) { if ($File == '.' || $File == '..') { continue; } $Path = $Dir . '/' . $File; if (is_dir($Path)) { ProcessDir($Path); } else { ProcessFile($Path); } } closedir($Dh); } }
function ProcessDir($dir) { global $src, $dest, $totalDirs, $totalFiles, $totalMinified; if (!file_exists($dest . substr($dir, strlen($src)))) { echo 'mkdir -> ' . $dest . substr($dir, strlen($src)) . "\n"; mkdir($dest . substr($dir, strlen($src))); } $dir .= EndsWith($dir, '/') ? '*' : '/*'; foreach (glob($dir) as $file) { if (is_dir($file)) { if (EndsWith($file, '_build')) { continue; } ++$totalDirs; ProcessDir($file); } else { if (EndsWith($file, '.zScript build ip') || EndsWith($file, '.gz') || EndsWith($file, '.bz2')) { continue; } else { if (EndsWith($file, '.js') && !EndsWith($file, '.min.js')) { echo 'UglifyJS -> ' . $dest . substr($file, strlen($src)) . "\n"; system('uglifyjs -o ' . $dest . substr($file, strlen($src)) . ' ' . $file); ++$totalMinified; } else { if (EndsWith($file, '.css')) { echo 'CleanCSS -> ' . $dest . substr($file, strlen($src)) . "\n"; system('cleancss --skip-rebase -o ' . $dest . substr($file, strlen($src)) . ' ' . $file); ++$totalMinified; } else { copy($file, $dest . substr($file, strlen($src))); } } } ++$totalFiles; } } }