Skip to content

Commit 818b47d

Browse files
Fixed autoloading when run from within vendor folder
1 parent c0c5cff commit 818b47d

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

bin/jp.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
#!/usr/bin/env php
22
<?php
3-
require __DIR__ . '/../vendor/autoload.php';
3+
4+
if (file_exists(__DIR__ . '/../vendor/autoload.php')) {
5+
require __DIR__ . '/../vendor/autoload.php';
6+
} elseif (file_exists(__DIR__ . '/../../../autoload.php')) {
7+
require __DIR__ . '/../../../autoload.php';
8+
} elseif (file_exists(__DIR__ . '/../autoload.php')) {
9+
require __DIR__ . '/../autoload.php';
10+
} else {
11+
throw new RuntimeException('Unable to locate autoload.php file.');
12+
}
413

514
use JmesPath\Env;
615
use JmesPath\DebugRuntime;

bin/perf.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
#!/usr/bin/env php
22
<?php
3-
require __DIR__ . '/../vendor/autoload.php';
3+
4+
if (file_exists(__DIR__ . '/../vendor/autoload.php')) {
5+
require __DIR__ . '/../vendor/autoload.php';
6+
} elseif (file_exists(__DIR__ . '/../../../autoload.php')) {
7+
require __DIR__ . '/../../../autoload.php';
8+
} else {
9+
throw new RuntimeException('Unable to locate autoload.php file.');
10+
}
411

512
$dir = isset($argv[1]) ? $argv[1] : __DIR__ . '/../tests/compliance/perf';
613
is_dir($dir) or die('Dir not found: ' . $dir);

0 commit comments

Comments
 (0)