| 1 | <?php
|
|---|
| 2 | /* A stripped down 'bumpbot' to reproduce YUI Compressor warnings */
|
|---|
| 3 | /* Based on http://core.trac.wordpress.org/attachment/ticket/19592/bumpbot.php */
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 | /* Designed to run from inside a trunk directory, since we'll fix warnings and pass over again we don't want to up, cleanup, revert, or checkout; work with what we've got */
|
|---|
| 7 | /* `svn up` regularly */
|
|---|
| 8 |
|
|---|
| 9 | if ( 'cli' != php_sapi_name() ) exit( 'Nuh-uh...' );
|
|---|
| 10 |
|
|---|
| 11 | if ( !file_exists( 'wp-load.php' ) ) exit( 'Where is WordPress?' );
|
|---|
| 12 |
|
|---|
| 13 | /* Add some color to this black and white world */
|
|---|
| 14 | $warning = "\x1b[1;31m";
|
|---|
| 15 | $ok = "\x1b[1;32m";
|
|---|
| 16 | $normal = "\x1b[0m";
|
|---|
| 17 |
|
|---|
| 18 | $bin = dirname( __FILE__ );
|
|---|
| 19 | $yui = $bin . '/yuicompressor-2.4.2.jar'; /* Get http://yuilibrary.com/download/yuicompressor/ */
|
|---|
| 20 |
|
|---|
| 21 | if ( !file_exists( $yui ) ) exit( 'Y U I?' );
|
|---|
| 22 |
|
|---|
| 23 | $yui = "java -jar $yui -v";
|
|---|
| 24 |
|
|---|
| 25 | $skip = 16 + 0; /* Useful for debugging particular files, there are 16 CSS files */
|
|---|
| 26 | $total = 0;
|
|---|
| 27 | foreach ( array('css', 'js') as $type ) {
|
|---|
| 28 | $files = explode( "\n", trim( `find . -name "*.dev.$type"` ) );
|
|---|
| 29 |
|
|---|
| 30 | $numfiles = sizeof( $files );
|
|---|
| 31 | $current = 0;
|
|---|
| 32 |
|
|---|
| 33 | foreach ( $files as $file ) {
|
|---|
| 34 | ++$current;
|
|---|
| 35 | if ( $total++ < $skip ) continue;
|
|---|
| 36 |
|
|---|
| 37 | $file = substr( $file, 0, -strlen( ".dev.$type" ) );
|
|---|
| 38 | $result = trim( `$yui --type $type -o $file.$type $file.dev.$type 2>&1` );
|
|---|
| 39 |
|
|---|
| 40 | if ( false === strpos( $result, '[WARNING]' ) )
|
|---|
| 41 | $result = "{$ok}OK{$normal}";
|
|---|
| 42 | else $result = $warning.strstr( $result, '[WARNING]' ).$normal;
|
|---|
| 43 |
|
|---|
| 44 | $noutof = "$current/$numfiles";
|
|---|
| 45 | $result = str_replace( "\n", "\n\t\t", $result );
|
|---|
| 46 | echo "$noutof: $file.dev.$type\n\t\t$result\n";
|
|---|
| 47 | }
|
|---|
| 48 | }
|
|---|
| 49 |
|
|---|
| 50 | echo "KTHNXBYE!\n";
|
|---|
| 51 | ?>
|
|---|