Skip to content

Commit b84819c

Browse files
authored
Merge pull request #945 from hydephp/update-vendor-path-helper-to-specify-which-package-to-use
Update Hyde::vendorPath() helper to allow a Hyde package to be specified
2 parents 86764a5 + 731b9eb commit b84819c

File tree

5 files changed

+18
-5
lines changed

5 files changed

+18
-5
lines changed

packages/framework/src/Foundation/Concerns/ForwardsFilesystem.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ public function path(string $path = ''): string
2323
return $this->filesystem->path($path);
2424
}
2525

26-
public function vendorPath(string $path = ''): string
26+
public function vendorPath(string $path = '', string $package = 'framework'): string
2727
{
28-
return $this->filesystem->vendorPath($path);
28+
return $this->filesystem->vendorPath($path, $package);
2929
}
3030

3131
public function copy(string $from, string $to): bool

packages/framework/src/Foundation/Filesystem.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ public function siteMediaPath(string $path = ''): string
134134
/**
135135
* Works similarly to the path() function, but returns a file in the Framework package.
136136
*/
137-
public function vendorPath(string $path = ''): string
137+
public function vendorPath(string $path = '', string $package = 'framework'): string
138138
{
139-
return $this->path('vendor/hyde/framework/'.unslash($path));
139+
return $this->path("vendor/hyde/$package/".unslash($path));
140140
}
141141

142142
/**

packages/framework/src/Hyde.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* @license MIT License
2626
*
2727
* @method static string path(string $path = '') $basePath
28-
* @method static string vendorPath(string $path = '')
28+
* @method static string vendorPath(string $path = '', string $package = 'framework')
2929
* @method static string pathToAbsolute(string $path)
3030
* @method static string pathToRelative(string $path)
3131
* @method static string getModelSourcePath(string $model, string $path = '')

packages/framework/tests/Feature/Foundation/FilesystemTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ public function test_vendor_path_method_returns_expected_value_regardless_of_tra
111111
$this->assertEquals('/foo/vendor/hyde/framework/file.php', $this->filesystem->vendorPath('\\//file.php/'));
112112
}
113113

114+
public function test_vendor_path_can_specify_which_hyde_package_to_use()
115+
{
116+
$this->assertDirectoryExists(Hyde::vendorPath(package: 'realtime-compiler'));
117+
$this->assertFileExists(Hyde::vendorPath('composer.json', 'realtime-compiler'));
118+
}
119+
114120
public function test_copy_method()
115121
{
116122
touch(Hyde::path('foo'));

packages/framework/tests/Unit/HydeVendorPathHelperTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,11 @@ public function test_method_returns_path_to_the_vendor_directory()
3131
$this->assertFileExists(Hyde::vendorPath().'/composer.json');
3232
$this->assertStringContainsString('"name": "hyde/framework",', file_get_contents(Hyde::vendorPath().'/composer.json'));
3333
}
34+
35+
public function test_can_specify_which_hyde_package_to_use()
36+
{
37+
$this->assertDirectoryExists(Hyde::vendorPath(package: 'realtime-compiler'));
38+
$this->assertFileExists(Hyde::vendorPath('composer.json', 'realtime-compiler'));
39+
$this->assertStringContainsString('"name": "hyde/realtime-compiler",', file_get_contents(Hyde::vendorPath('composer.json', 'realtime-compiler')));
40+
}
3441
}

0 commit comments

Comments
 (0)