MediaWiki  REL1_22
checkLess.php
Go to the documentation of this file.
00001 <?php
00024 require_once __DIR__ . '/Maintenance.php';
00025 
00029 class CheckLess extends Maintenance {
00030     public function __construct() {
00031         parent::__construct();
00032         $this->mDescription = 'Checks LESS files for errors';
00033     }
00034 
00035     public function execute() {
00036         $result = false;
00037         $resourceLoader = new ResourceLoader();
00038         foreach ( $resourceLoader->getModuleNames() as $name ) {
00040             $module = $resourceLoader->getModule( $name );
00041             if ( !$module || !$module instanceof ResourceLoaderFileModule ) {
00042                 continue;
00043             }
00044 
00045             $hadErrors = false;
00046             foreach ( $module->getAllStyleFiles() as $file ) {
00047                 if ( $module->getStyleSheetLang( $file ) !== 'less' ) {
00048                     continue;
00049                 }
00050                 try {
00051                     $compiler = ResourceLoader::getLessCompiler();
00052                     $compiler->compileFile( $file );
00053                 } catch ( Exception $e ) {
00054                     if ( !$hadErrors ) {
00055                         $this->error( "Errors checking module $name:\n" );
00056                         $hadErrors = true;
00057                     }
00058                     $this->error( $e->getMessage() . "\n" );
00059                     $result = true;
00060                 }
00061             }
00062         }
00063         if ( !$result ) {
00064             $this->output( "No errors found\n" );
00065         } else {
00066             die( 1 );
00067         }
00068     }
00069 }
00070 
00071 $maintClass = 'CheckLess';
00072 require_once RUN_MAINTENANCE_IF_MAIN;