read()) { if(substr($entry, 0, 1) == '.') continue; if($entry == 'dtree.js' || $entry == 'IE9.js' || $entry == 'md5.js' || $entry == 'pngfix.js') continue; if(substr($entry, -3) == '.js' && strpos($entry, '.uncompressed.') === false) $files[] = $dir.$entry; } $d->close(); foreach($files as $file) { $backupFile = substr($file, 0, -3) . '.uncompressed.js'; if(file_exists($backupFile)) { echo ' File already compressed: ' . basename($file) . "\n"; continue; } echo ' Storing uncompressed version of ' . basename($file) . ' in ' . basename($backupFile) . "\n"; if(!copy($file, $backupFile)) { echo ' FAILED' . "\n"; continue; } $out = ''; $ret = 1; exec("java -jar ".dirname(__FILE__)."/yui-compressor/yuicompressor-2.4.8.jar --nomunge --type js -o \"$file\" \"$backupFile\"", $out, $ret); if($ret != 0) echo ' YUI compressor failed for ' . $file . "\n"; }