validateRegistrationFile: Accept glob patterns
authorKunal Mehta <legoktm@member.fsf.org>
Sat, 23 Feb 2019 04:44:10 +0000 (20:44 -0800)
committerKrinkle <krinklemail@gmail.com>
Sat, 2 Mar 2019 22:59:17 +0000 (22:59 +0000)
I've had this locally for a while now - it makes it easier to validate all
extension.json files that you might have checked out. The only catch is that
you have to escape the glob pattern from your shell.

Change-Id: Ic220034574129fab9e850f91c05dbd5e241f556c

maintenance/validateRegistrationFile.php

index 4b07796..0d6cfa2 100644 (file)
@@ -5,19 +5,25 @@ require_once __DIR__ . '/Maintenance.php';
 class ValidateRegistrationFile extends Maintenance {
        public function __construct() {
                parent::__construct();
-               $this->addArg( 'path', 'Path to extension.json/skin.json file.', true );
+               $this->addArg(
+                       'path',
+                       'Path or glob pattern to extension.json/skin.json file.',
+                       true
+               );
        }
        public function execute() {
                $validator = new ExtensionJsonValidator( function ( $msg ) {
                        $this->fatalError( $msg );
                } );
                $validator->checkDependencies();
-               $path = $this->getArg( 0 );
-               try {
-                       $validator->validate( $path );
-                       $this->output( "$path validates against the schema!\n" );
-               } catch ( ExtensionJsonValidationError $e ) {
-                       $this->fatalError( $e->getMessage() );
+               $paths = glob( $this->getArg( 0 ) );
+               foreach ( $paths as $path ) {
+                       try {
+                               $validator->validate( $path );
+                               $this->output( "$path validates against the schema!\n" );
+                       } catch ( ExtensionJsonValidationError $e ) {
+                               $this->fatalError( $e->getMessage() );
+                       }
                }
        }
 }