Skip to content

Commit 20759dd

Browse files
committed
fix path
1 parent 1c37af6 commit 20759dd

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

‎.github/scripts/validatePluginJson.php‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,39 +32,42 @@ function findPluginJsonFiles(string $dir): array
3232
* Validate a `plugin.json` file to ensure it does not contain a "meta" key.
3333
*
3434
* @param string $file Path to the JSON file.
35+
* @param string $relativePath Relative path to the file for better output clarity.
3536
* @return string|null Error message if invalid, or null if valid.
3637
*/
37-
function validateJsonFile(string $file): ?string
38+
function validateJsonFile(string $file, string $relativePath): ?string
3839
{
3940
$content = file_get_contents($file);
4041

4142
if ($content === false) {
42-
return "Failed to read $file.";
43+
return "Failed to read $relativePath.";
4344
}
4445

4546
$json = json_decode($content, true);
4647

4748
if (json_last_error() !== JSON_ERROR_NONE) {
48-
return "Invalid JSON in $file: " . json_last_error_msg();
49+
return "Invalid JSON in $relativePath: " . json_last_error_msg();
4950
}
5051

5152
if (array_key_exists('meta', $json)) {
52-
return "$file contains a 'meta' key. Please remove it.";
53+
return "$relativePath contains a 'meta' key. Please remove it.";
5354
}
5455

5556
return null;
5657
}
5758

58-
$root = __DIR__ . '/../../';
59+
$root = realpath(__DIR__ . '/../../');
5960
$pluginJsonFiles = findPluginJsonFiles($root);
6061

6162
echo 'Found ' . count($pluginJsonFiles) . " plugin.json file(s) to validate.\n";
6263

6364
$errors = [];
6465

6566
foreach ($pluginJsonFiles as $file) {
66-
echo "Validating $file...\n";
67-
$error = validateJsonFile($file);
67+
$relativePath = str_replace($root . DIRECTORY_SEPARATOR, '', $file);
68+
69+
echo "Validating $relativePath...\n";
70+
$error = validateJsonFile($file, $relativePath);
6871

6972
if ($error !== null) {
7073
$errors[] = $error;

0 commit comments

Comments
 (0)