Skip to content

Instantly share code, notes, and snippets.

@emad-elsaid
Created March 12, 2011 16:19
Show Gist options
  • Save emad-elsaid/867340 to your computer and use it in GitHub Desktop.
Save emad-elsaid/867340 to your computer and use it in GitHub Desktop.
this script i put it beside the dojo and dijit directories, i used it to remove new lines from javascript files in all the dojo project, recursively
<?php
function explore( $path ){
$files = scandir( $path );
$files = array_slice( $files, 2);
foreach( $files as $file )
if( is_dir( $path.'/'.$file ) )
explore( $path.'/'.$file );
else
process( $path.'/'.$file );
}
function process( $file ){
if( substr( $file, strlen($file)-3 )=='.js' )
{
echo $file."\n";
$text = file_get_contents( $file );
$text = str_replace( array("\r\n", "\n", "\r"), "", $text );
file_put_contents( $file, $text );
}
}
// directories to process
explore('dojo');
explore('dijit');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment