Skip to content

Commit 8dc4a52

Browse files
committed
Calling the Include::path() method will no longer create the directory
It feels weird that this creates the directory, and it violates the principle of least astonishment as it's surprising that this creates a directory when you just request the path. Fixes #1706
1 parent a954901 commit 8dc4a52

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

RELEASE_NOTES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ This serves two purposes:
2323
- The `hasFeature` method on the Hyde facade and HydeKernel now only accepts a Feature enum value instead of a string for its parameter.
2424
- Changed how the documentation search is generated, to be an `InMemoryPage` instead of a post-build task.
2525
- Media asset files are now copied using the new build task instead of the deprecated `BuildService::transferMediaAssets()` method.
26+
- Calling the `Include::path()` method will no longer create the includes directory in https://github.com/hydephp/develop/pull/1707
27+
2628

2729
### Deprecated
2830
- for soon-to-be removed features.

packages/framework/src/Support/Includes.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use Hyde\Hyde;
88
use Hyde\Markdown\Models\Markdown;
99
use Illuminate\Support\Facades\Blade;
10-
use Hyde\Framework\Concerns\InteractsWithDirectories;
1110

1211
use function basename;
1312
use function file_exists;
@@ -20,8 +19,6 @@
2019
*/
2120
class Includes
2221
{
23-
use InteractsWithDirectories;
24-
2522
/**
2623
* @var string The directory where includes are stored.
2724
*/
@@ -35,8 +32,6 @@ class Includes
3532
*/
3633
public static function path(?string $filename = null): string
3734
{
38-
static::needsDirectory(static::$includesDirectory);
39-
4035
return $filename === null
4136
? Hyde::path(static::$includesDirectory)
4237
: Hyde::path(static::$includesDirectory.'/'.$filename);

packages/framework/tests/Feature/IncludesFacadeTest.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,20 @@
1515
*/
1616
class IncludesFacadeTest extends TestCase
1717
{
18+
protected function setUp(): void
19+
{
20+
parent::setUp();
21+
22+
File::makeDirectory(Includes::path(), recursive: true);
23+
}
24+
25+
public function tearDown(): void
26+
{
27+
File::deleteDirectory(Includes::path());
28+
29+
parent::tearDown();
30+
}
31+
1832
public function testPathReturnsTheIncludesDirectory()
1933
{
2034
$this->assertSame(
@@ -31,14 +45,6 @@ public function testPathReturnsAPartialWithinTheIncludesDirectory()
3145
);
3246
}
3347

34-
public function testPathCreatesDirectoryIfItDoesNotExist()
35-
{
36-
$path = Includes::path();
37-
File::deleteDirectory($path);
38-
$this->assertFalse(File::exists($path));
39-
$this->assertTrue(File::exists(Includes::path()));
40-
}
41-
4248
public function testGetReturnsPartial()
4349
{
4450
$expected = 'foo bar';

0 commit comments

Comments
 (0)