Skip to content

Commit b836712

Browse files
authored
Merge pull request #460 from hydephp/refactor-build-tasks
Update build task output messages
2 parents 1100a10 + cb6926c commit b836712

File tree

5 files changed

+14
-18
lines changed

5 files changed

+14
-18
lines changed

packages/framework/src/Actions/PostBuildTasks/GenerateRssFeed.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ public function run(): void
2020

2121
public function then(): void
2222
{
23-
$this->writeln(sprintf("\n > Created <info>%s</info> in %s",
24-
RssFeedService::getDefaultOutputFilename(),
25-
$this->getExecutionTime()
26-
));
23+
$this->createdSiteFile('_site/'.RssFeedService::getDefaultOutputFilename())->withExecutionTime();
2724
}
2825
}

packages/framework/src/Actions/PostBuildTasks/GenerateSearch.php

+1-9
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,7 @@ public function run(): void
3131

3232
public function then(): void
3333
{
34-
$this->writeln(sprintf("\n > Created <info>%s</info> in %s",
35-
$this->normalizePath(DocumentationSearchService::$filePath),
36-
$this->getExecutionTime()
37-
));
38-
}
39-
40-
protected function normalizePath(string $path): string
41-
{
42-
return str_replace('\\', '/', $path);
34+
$this->createdSiteFile(DocumentationSearchService::$filePath)->withExecutionTime();
4335
}
4436

4537
/** @internal Estimated processing time per file in ms */

packages/framework/src/Actions/PostBuildTasks/GenerateSitemap.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ public function run(): void
2020

2121
public function then(): void
2222
{
23-
$this->writeln(sprintf("\n > Created <info>sitemap.xml</info> in %s",
24-
$this->getExecutionTime()
25-
));
23+
$this->createdSiteFile('_site/sitemap.xml')->withExecutionTime();
2624
}
2725
}

packages/framework/src/Contracts/AbstractBuildTask.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,19 @@ public function writeln(string $message): void
6969
$this->output?->writeln($message);
7070
}
7171

72-
public function createdSiteFile(string $path): void
72+
public function createdSiteFile(string $path): static
7373
{
7474
$this->write(sprintf("\n > Created <info>%s</info>",
7575
str_replace('\\', '/', Hyde::pathToRelative($path))
7676
));
77+
78+
return $this;
79+
}
80+
81+
public function withExecutionTime(): static
82+
{
83+
$this->write(" in {$this->getExecutionTime()}");
84+
85+
return $this;
7786
}
7887
}

packages/framework/tests/Feature/Services/BuildTaskServiceTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function test_build_command_can_run_post_build_tasks()
2828

2929
$this->artisan('build')
3030
->expectsOutputToContain('Generating sitemap')
31-
->expectsOutputToContain('Created sitemap.xml')
31+
->expectsOutputToContain('Created _site/sitemap.xml')
3232
->assertExitCode(0);
3333

3434
File::cleanDirectory(Hyde::path('_site'));

0 commit comments

Comments
 (0)