Skip to content
Merged
Changes from all commits
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
27 changes: 22 additions & 5 deletions src/bundle/Command/CompileAssetsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,18 @@ 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',
$this->timeout
"Timeout in seconds (default timeout is {$this->timeout}s when this option isn't used and not in watch mode)",
null
)
->addOption(
'config-name',
Expand All @@ -63,10 +69,16 @@ protected function configure(): void

protected function initialize(InputInterface $input, OutputInterface $output): void
{
$watch = $input->getOption('watch');
$timeout = $input->getOption('timeout');

if (!is_numeric($timeout)) {
throw new InvalidArgumentException('Timeout value has to be an integer.');
if (null !== $timeout) {
if ($watch) {
throw new InvalidArgumentException('Watch mode can\'t be used with a timeout.');
}
if (!is_numeric($timeout)) {
throw new InvalidArgumentException('Timeout value has to be an integer.');
}
}
}

Expand All @@ -77,7 +89,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') ?? $this->timeout);
$env = $input->getOption('env');
$configName = $input->getOption('config-name');
$frontendConfigsName = $input->getOption('frontend-configs-name');
Expand All @@ -89,6 +102,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