Skip to content

Commit ea035f1

Browse files
authored
Merge pull request #1327 from hydephp/update-playcdn-integration-to-work-gracefully-when-there-is-no-tailwind-config-file
Update AssetService::injectTailwindConfig method to handle missing config file gracefully
2 parents f0dca12 + 6b293c3 commit ea035f1

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

RELEASE_NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ This release is the first since the official release of HydePHP 1.0.0. It contai
2626
- Fixed https://github.com/hydephp/develop/issues/1320 in https://github.com/hydephp/develop/pull/1321
2727
- Fixed https://github.com/hydephp/develop/issues/1322 in https://github.com/hydephp/develop/issues/1323
2828
- Fixed https://github.com/hydephp/develop/issues/1324 in https://github.com/hydephp/develop/pull/1325
29+
- Fixed https://github.com/hydephp/develop/issues/1326 in https://github.com/hydephp/develop/pull/1327
2930
- Added missing function imports in https://github.com/hydephp/develop/pull/1309
3031

3132
### Security

packages/framework/src/Framework/Services/AssetService.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ public function hasMediaFile(string $file): bool
6767

6868
public function injectTailwindConfig(): string
6969
{
70+
if (! file_exists(Hyde::path('tailwind.config.js'))) {
71+
return '';
72+
}
73+
7074
$config = Str::between(file_get_contents(Hyde::path('tailwind.config.js')), '{', '}');
7175

7276
// Remove the plugins array, as it is not used in the frontend.

packages/framework/tests/Unit/AssetServiceUnitTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Hyde\Framework\Services\AssetService;
88
use Hyde\Testing\UnitTestCase;
9+
use Hyde\Hyde;
910

1011
/**
1112
* @covers \Hyde\Framework\Services\AssetService
@@ -107,4 +108,12 @@ public function testInjectTailwindConfigReturnsExtractedTailwindConfig()
107108
$this->assertStringContainsString('typography: {', $config);
108109
$this->assertStringNotContainsString('plugins', $config);
109110
}
111+
112+
public function testInjectTailwindConfigHandlesMissingConfigFileGracefully()
113+
{
114+
rename(Hyde::path('tailwind.config.js'), Hyde::path('tailwind.config.js.bak'));
115+
$this->assertIsString((new AssetService())->injectTailwindConfig());
116+
$this->assertSame('', (new AssetService())->injectTailwindConfig());
117+
rename(Hyde::path('tailwind.config.js.bak'), Hyde::path('tailwind.config.js'));
118+
}
110119
}

0 commit comments

Comments
 (0)