Skip to content

Commit

Permalink
Merge pull request #460 from hydephp/refactor-build-tasks
Browse files Browse the repository at this point in the history
Update build task output messages
  • Loading branch information
caendesilva authored Sep 1, 2022
2 parents 1100a10 + cb6926c commit b836712
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ public function run(): void

public function then(): void
{
$this->writeln(sprintf("\n > Created <info>%s</info> in %s",
RssFeedService::getDefaultOutputFilename(),
$this->getExecutionTime()
));
$this->createdSiteFile('_site/'.RssFeedService::getDefaultOutputFilename())->withExecutionTime();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,7 @@ public function run(): void

public function then(): void
{
$this->writeln(sprintf("\n > Created <info>%s</info> 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 */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ public function run(): void

public function then(): void
{
$this->writeln(sprintf("\n > Created <info>sitemap.xml</info> in %s",
$this->getExecutionTime()
));
$this->createdSiteFile('_site/sitemap.xml')->withExecutionTime();
}
}
11 changes: 10 additions & 1 deletion packages/framework/src/Contracts/AbstractBuildTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <info>%s</info>",
str_replace('\\', '/', Hyde::pathToRelative($path))
));

return $this;
}

public function withExecutionTime(): static
{
$this->write(" in {$this->getExecutionTime()}");

return $this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down

0 comments on commit b836712

Please sign in to comment.