Skip to content

Commit a2b5b96

Browse files
Adrian FöderAdrian Föder
Adrian Föder
authored and
Adrian Föder
committed
[BUGFIX] Make autoloader resolve more stable
This fixes a bug where the autoloader couldn't be found when executed in different, unexpected contexts
1 parent e21d3f2 commit a2b5b96

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

scripts/php-css-lint

100644100755
Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,20 @@ echo PHP_EOL.
1111
' |_| '.PHP_EOL.PHP_EOL.
1212
'==========================================================='.PHP_EOL.PHP_EOL;
1313

14-
if(file_exists($sComposerAutoloader = __DIR__.'/../vendor/autoload.php')){
15-
require $sComposerAutoloader;
14+
$sComposerAutoloaderWorkingDirectory = getcwd() . '/vendor/autoload.php';
15+
if (is_file($sComposerAutoloaderWorkingDirectory)) {
16+
require_once $sComposerAutoloaderWorkingDirectory;
1617
}
17-
else {
18-
printError('Composer autoload file "'.$sComposerAutoloader.'" does not exist');
19-
exit(1);
18+
19+
if (!class_exists('CssLint\Linter', true)) {
20+
// consider being in bin dir
21+
$sComposerAutoloader = __DIR__ . '/../vendor/autoload.php';
22+
if (!is_file($sComposerAutoloader)) {
23+
// consider being in vendor/neilime/php-css-lint/scripts
24+
$sComposerAutoloader = __DIR__ . '/../../../autoload.php';
25+
}
26+
27+
require_once $sComposerAutoloader;
2028
}
2129

2230
function printUsage(){

0 commit comments

Comments
 (0)