diff --git a/packages/framework/src/Actions/PostBuildTasks/GenerateRssFeed.php b/packages/framework/src/Actions/PostBuildTasks/GenerateRssFeed.php index 2e901794226..d325326b583 100644 --- a/packages/framework/src/Actions/PostBuildTasks/GenerateRssFeed.php +++ b/packages/framework/src/Actions/PostBuildTasks/GenerateRssFeed.php @@ -20,9 +20,6 @@ public function run(): void public function then(): void { - $this->writeln(sprintf("\n > Created %s in %s", - RssFeedService::getDefaultOutputFilename(), - $this->getExecutionTime() - )); + $this->createdSiteFile('_site/'.RssFeedService::getDefaultOutputFilename())->withExecutionTime(); } } diff --git a/packages/framework/src/Actions/PostBuildTasks/GenerateSearch.php b/packages/framework/src/Actions/PostBuildTasks/GenerateSearch.php index 7071a12880a..3f0547c4feb 100644 --- a/packages/framework/src/Actions/PostBuildTasks/GenerateSearch.php +++ b/packages/framework/src/Actions/PostBuildTasks/GenerateSearch.php @@ -31,15 +31,7 @@ public function run(): void public function then(): void { - $this->writeln(sprintf("\n > Created %s in %s", - $this->normalizePath(DocumentationSearchService::$filePath), - $this->getExecutionTime() - )); - } - - protected function normalizePath(string $path): string - { - return str_replace('\\', '/', $path); + $this->createdSiteFile(DocumentationSearchService::$filePath)->withExecutionTime(); } /** @internal Estimated processing time per file in ms */ diff --git a/packages/framework/src/Actions/PostBuildTasks/GenerateSitemap.php b/packages/framework/src/Actions/PostBuildTasks/GenerateSitemap.php index 3e8f893803a..d03fca7fad3 100644 --- a/packages/framework/src/Actions/PostBuildTasks/GenerateSitemap.php +++ b/packages/framework/src/Actions/PostBuildTasks/GenerateSitemap.php @@ -20,8 +20,6 @@ public function run(): void public function then(): void { - $this->writeln(sprintf("\n > Created sitemap.xml in %s", - $this->getExecutionTime() - )); + $this->createdSiteFile('_site/sitemap.xml')->withExecutionTime(); } } diff --git a/packages/framework/src/Contracts/AbstractBuildTask.php b/packages/framework/src/Contracts/AbstractBuildTask.php index 23c8264c238..6ca153ad808 100644 --- a/packages/framework/src/Contracts/AbstractBuildTask.php +++ b/packages/framework/src/Contracts/AbstractBuildTask.php @@ -69,10 +69,19 @@ public function writeln(string $message): void $this->output?->writeln($message); } - public function createdSiteFile(string $path): void + public function createdSiteFile(string $path): static { $this->write(sprintf("\n > Created %s", str_replace('\\', '/', Hyde::pathToRelative($path)) )); + + return $this; + } + + public function withExecutionTime(): static + { + $this->write(" in {$this->getExecutionTime()}"); + + return $this; } } diff --git a/packages/framework/tests/Feature/Services/BuildTaskServiceTest.php b/packages/framework/tests/Feature/Services/BuildTaskServiceTest.php index 72bd2aca621..27aec45eea8 100644 --- a/packages/framework/tests/Feature/Services/BuildTaskServiceTest.php +++ b/packages/framework/tests/Feature/Services/BuildTaskServiceTest.php @@ -28,7 +28,7 @@ public function test_build_command_can_run_post_build_tasks() $this->artisan('build') ->expectsOutputToContain('Generating sitemap') - ->expectsOutputToContain('Created sitemap.xml') + ->expectsOutputToContain('Created _site/sitemap.xml') ->assertExitCode(0); File::cleanDirectory(Hyde::path('_site'));