手册:jsparse.php
Appearance
| MediaWiki文件: jsparse.php | |
|---|---|
| 位置: | maintenance/ |
| 源代码: | master • 1.45.1 • 1.44.3 • 1.43.6 |
| 类: | JSParseHelper |
细节
jsparse.php file is a maintenance script for testing JavaScript validity using JSMin+'s parser. This is a useful feature to run parsing/syntax check on JavaScript files.
选项/参数
This script takes the filenames of the files to be validated as arguments, separated by spaces.
用法
php maintenance/run.php jsparse filename
在MediaWiki MediaWiki 1.39及更早版本中,您必须通过
php maintenance/脚本名称.php调用维护脚本,而不是php maintenance/run.php 脚本名称。Checking valid file
example.js
$( function () {
var $longList = $("#longList").addClass("grid_row");
var $leftDiv = $("<div>");
var $rightDiv = $("<div>");
$longList.append($leftDiv, $rightDiv);
});
Terminal
$ php maintenance/run.php jsparse example.js example.js OK
Checking invalid file
example.js
$( function () {
var $longList = $("#longList").addClass("grid_row");
var $leftDiv = $("<div>");
var $rightDiv = $("<div>");
// Intentionally removed `);` from the end for the jsparse.php demo
$longList.append($leftDiv, $rightDiv
});
Terminal
$ php maintenance/run.php jsparse example.js example.js ERROR: Parse error: Missing ) in parenthetical in file 'example.js' on line 7 Failed.
Common error
- $filename ERROR: could not read file
This error occurs when the file does not exist or the user running the script does not have permission to read the file.
If the file does exist, check the file permissions. If you are root user, then you can run the script with sudo.
参见
- 手册:Eval.php (PHP interpreter)
- Manual:如何调试
- ResourceLoader/Architecture#Debug mode