3 * Maintenance script to do test JavaScript validity parses using jsmin+'s parser
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
20 * @ingroup Maintenance
23 require_once( dirname( __FILE__
) . '/Maintenance.php' );
25 class JSParseHelper
extends Maintenance
{
28 public function __construct() {
29 parent
::__construct();
30 $this->mDescription
= "Runs parsing/syntax checks on JavaScript files";
31 $this->addArg( 'file(s)', 'JavaScript file to test', false );
34 public function execute() {
35 if ( $this->hasArg() ) {
36 $files = $this->mArgs
;
38 $this->maybeHelp( true ); // @fixme this is a lame API :)
39 exit( 1 ); // it should exit from the above first...
42 $parser = new JSParser();
43 foreach ( $files as $filename ) {
45 $js = file_get_contents( $filename );
48 $this->output( "$filename ERROR: could not read file\n" );
54 $parser->parse( $js, $filename, 1 );
55 } catch (Exception
$e) {
57 $this->output( "$filename ERROR: " . $e->getMessage() . "\n" );
61 $this->output( "$filename OK\n" );
64 if ($this->errs
> 0) {
70 $maintClass = "JSParseHelper";
71 require_once( RUN_MAINTENANCE_IF_MAIN
);