Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/bundle/Command/CompileAssetsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,17 @@ public function __construct(int $timeout = self::COMMAND_DEFAULT_TIMEOUT)
protected function configure(): void
{
$this
->addOption(
'watch',
'w',
InputOption::VALUE_NONE,
'Watch mode rebuilds on file change'
)
->addOption(
'timeout',
't',
InputOption::VALUE_REQUIRED,
'Timeout in seconds',
'Timeout in seconds (ignored in watch mode)',
$this->timeout
)
->addOption(
Expand Down Expand Up @@ -77,7 +83,8 @@ protected function getFrontendConfigPath(string $configName): string

protected function execute(InputInterface $input, OutputInterface $output): int
{
$timeout = (float)$input->getOption('timeout');
$watch = $input->getOption('watch');
$timeout = $watch ? null : (float)$input->getOption('timeout');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If someone passes --timeout, but we silently discard it due to --watch, it should raise an error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In 84aab74...a220c2d I implemented the error when both options are used at the same time --watch --timeout 123.
To be able to detected if the user passed the --timeout option, I had to remove its default value from definition.

$env = $input->getOption('env');
$configName = $input->getOption('config-name');
$frontendConfigsName = $input->getOption('frontend-configs-name');
Expand All @@ -89,6 +96,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$yarnBaseEncoreCommand = "yarn encore {$encoreEnv}";
$yarnEncoreCommand = $yarnBaseEncoreCommand;

if ($watch) {
$yarnEncoreCommand = "{$yarnBaseEncoreCommand} --watch";
}

if (!empty($configName)) {
$yarnEncoreCommand = "{$yarnBaseEncoreCommand} --config-name {$configName}";
}
Expand Down
Loading