Skip to content

Commit

Permalink
Merge branch 'master' into separate-internal-application-files-from-p…
Browse files Browse the repository at this point in the history
…roject-structure-
  • Loading branch information
caendesilva authored Feb 9, 2023
2 parents 6b32a15 + b84819c commit f41bc7f
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ public function path(string $path = ''): string
return $this->filesystem->path($path);
}

public function vendorPath(string $path = ''): string
public function vendorPath(string $path = '', string $package = 'framework'): string
{
return $this->filesystem->vendorPath($path);
return $this->filesystem->vendorPath($path, $package);
}

public function copy(string $from, string $to): bool
Expand Down
4 changes: 2 additions & 2 deletions packages/framework/src/Foundation/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ public function siteMediaPath(string $path = ''): string
/**
* Works similarly to the path() function, but returns a file in the Framework package.
*/
public function vendorPath(string $path = ''): string
public function vendorPath(string $path = '', string $package = 'framework'): string
{
return $this->path('vendor/hyde/framework/'.unslash($path));
return $this->path("vendor/hyde/$package/".unslash($path));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/framework/src/Hyde.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* @license MIT License
*
* @method static string path(string $path = '') $basePath
* @method static string vendorPath(string $path = '')
* @method static string vendorPath(string $path = '', string $package = 'framework')
* @method static string pathToAbsolute(string $path)
* @method static string pathToRelative(string $path)
* @method static string getModelSourcePath(string $model, string $path = '')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ public function test_vendor_path_method_returns_expected_value_regardless_of_tra
$this->assertEquals('/foo/vendor/hyde/framework/file.php', $this->filesystem->vendorPath('\\//file.php/'));
}

public function test_vendor_path_can_specify_which_hyde_package_to_use()
{
$this->assertDirectoryExists(Hyde::vendorPath(package: 'realtime-compiler'));
$this->assertFileExists(Hyde::vendorPath('composer.json', 'realtime-compiler'));
}

public function test_copy_method()
{
touch(Hyde::path('foo'));
Expand Down
7 changes: 7 additions & 0 deletions packages/framework/tests/Unit/HydeVendorPathHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,11 @@ public function test_method_returns_path_to_the_vendor_directory()
$this->assertFileExists(Hyde::vendorPath().'/composer.json');
$this->assertStringContainsString('"name": "hyde/framework",', file_get_contents(Hyde::vendorPath().'/composer.json'));
}

public function test_can_specify_which_hyde_package_to_use()
{
$this->assertDirectoryExists(Hyde::vendorPath(package: 'realtime-compiler'));
$this->assertFileExists(Hyde::vendorPath('composer.json', 'realtime-compiler'));
$this->assertStringContainsString('"name": "hyde/realtime-compiler",', file_get_contents(Hyde::vendorPath('composer.json', 'realtime-compiler')));
}
}

0 comments on commit f41bc7f

Please sign in to comment.