Skip to content

Commit

Permalink
Fix binary vendor autoload?
Browse files Browse the repository at this point in the history
  • Loading branch information
SRWieZ committed Nov 1, 2023
1 parent 35d708f commit 10fde52
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
7 changes: 7 additions & 0 deletions bin/svgtinyps
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#!/usr/bin/env php
<?php

if (file_exists(__DIR__.'/../../../autoload.php')) {
require __DIR__.'/../../../autoload.php';
} else {
require __DIR__.'/../vendor/autoload.php';
}

require __DIR__.'/../src/svgtinyps.php';
19 changes: 11 additions & 8 deletions src/svgtinyps.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

use SVGTinyPS\SVGTinyPS;

require __DIR__.'/../vendor/autoload.php';
if (class_exists('\Composer\InstalledVersions')) {
require __DIR__.'/../vendor/autoload.php';
}

// Argument parsing
$options = getopt('v', ['verbose']);
$isVerbose = isset($options['v']) || isset($options['verbose']);
Expand Down Expand Up @@ -60,14 +63,14 @@ function showHelp()
echo php_sapi_name() == 'micro' ? ' Compiled with https://github.com/crazywhalecc/static-php-cli'.PHP_EOL : '';
}

if (! $command || $command === 'help') {
if ( ! $command || $command === 'help') {
showHelp();
exit;
}

$inputFile = $argv[1] ?? null;

if (! $inputFile || ! file_exists($inputFile)) {
if ( ! $inputFile || ! file_exists($inputFile)) {
echo "Error: Input file not provided or doesn't exist.".PHP_EOL;
exit(1);
}
Expand All @@ -84,7 +87,7 @@ function showHelp()
exit(1);
}

if ($outputDir && (! is_dir($outputDir) || ! is_writable($outputDir))) {
if ($outputDir && ( ! is_dir($outputDir) || ! is_writable($outputDir))) {
echo "Error: The output directory either does not exist or is not writeable.\n";
exit(1);
}
Expand All @@ -96,10 +99,10 @@ function showHelp()
verboseLog('Checking for SVG issues', $isVerbose);
checkIssues($inputFile, $isVerbose);
break;
// case 'minify':
// verboseLog('Starting SVG minification', $isVerbose);
// minifySvg($inputFile, $isVerbose);
// break;
// case 'minify':
// verboseLog('Starting SVG minification', $isVerbose);
// minifySvg($inputFile, $isVerbose);
// break;
default:
echo 'Invalid command.'.PHP_EOL;
showHelp();
Expand Down

0 comments on commit 10fde52

Please sign in to comment.