Skip to content

Commit

Permalink
Update PharSupport vendor path method to support more packages
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Dec 12, 2023
1 parent 6c478b3 commit 68f8539
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 16 deletions.
7 changes: 1 addition & 6 deletions packages/framework/src/Foundation/PharSupport.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use Hyde\Hyde;
use Phar;
use BadMethodCallException;

use function dirname;
use function is_dir;
Expand Down Expand Up @@ -47,10 +46,6 @@ public static function hasVendorDirectory(): bool

public static function vendorPath(string $path = '', string $package = 'framework'): string
{
if ($package !== 'framework') {
throw new BadMethodCallException('Cannot use vendorPath() outside of the framework package when running from a Phar archive.');
}

return rtrim(str_replace('/', DIRECTORY_SEPARATOR, rtrim(dirname(__DIR__, 2).'/'.$path, '/\\')), '/\\');
return rtrim(str_replace('/', DIRECTORY_SEPARATOR, rtrim(dirname(__DIR__, 3).'/'.$package.'/'.$path, '/\\')), '/\\');
}
}
10 changes: 0 additions & 10 deletions packages/framework/tests/Feature/PharSupportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,6 @@ public function test_vendor_path_can_run_in_phar_with_path_argument()
$this->assertEquals($this->replaceSlashes(Hyde::path("{$this->getBaseVendorPath()}/framework/file.php")), Hyde::vendorPath('file.php'));
}

public function test_vendor_path_can_run_in_phar_with_package_argument_but_throws()
{
PharSupport::mock('running', true);
PharSupport::mock('hasVendorDirectory', false);

$this->expectException(BadMethodCallException::class);

Hyde::vendorPath(package: 'realtime-compiler');
}

protected function getBaseVendorPath(): string
{
// Monorepo support for symlinked packages directory
Expand Down

0 comments on commit 68f8539

Please sign in to comment.