Skip to content

Commit 84aab74

Browse files
committed
CompileAssetsCommand.php: Add --watch
1 parent 226a63f commit 84aab74

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/bundle/Command/CompileAssetsCommand.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,17 @@ public function __construct(int $timeout = self::COMMAND_DEFAULT_TIMEOUT)
3737
protected function configure(): void
3838
{
3939
$this
40+
->addOption(
41+
'watch',
42+
'w',
43+
InputOption::VALUE_NONE,
44+
'Watch mode rebuilds on file change'
45+
)
4046
->addOption(
4147
'timeout',
4248
't',
4349
InputOption::VALUE_REQUIRED,
44-
'Timeout in seconds',
50+
'Timeout in seconds (ignored in watch mode)',
4551
$this->timeout
4652
)
4753
->addOption(
@@ -77,7 +83,8 @@ protected function getFrontendConfigPath(string $configName): string
7783

7884
protected function execute(InputInterface $input, OutputInterface $output): int
7985
{
80-
$timeout = (float)$input->getOption('timeout');
86+
$watch = $input->getOption('watch');
87+
$timeout = $watch ? null : (float)$input->getOption('timeout');
8188
$env = $input->getOption('env');
8289
$configName = $input->getOption('config-name');
8390
$frontendConfigsName = $input->getOption('frontend-configs-name');
@@ -89,6 +96,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8996
$yarnBaseEncoreCommand = "yarn encore {$encoreEnv}";
9097
$yarnEncoreCommand = $yarnBaseEncoreCommand;
9198

99+
if ($watch) {
100+
$yarnEncoreCommand = "{$yarnBaseEncoreCommand} --watch";
101+
}
102+
92103
if (!empty($configName)) {
93104
$yarnEncoreCommand = "{$yarnBaseEncoreCommand} --config-name {$configName}";
94105
}

0 commit comments

Comments
 (0)