From 94aacd09016687653f8542c21857cfce9d99227b Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Wed, 9 Mar 2011 02:30:19 +0100 Subject: [PATCH] [AsseticBundle] Throw exception if --watch is used without --debug. --- .../Bundle/AsseticBundle/Command/DumpCommand.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Bundle/AsseticBundle/Command/DumpCommand.php b/src/Symfony/Bundle/AsseticBundle/Command/DumpCommand.php index 0d7bde94db..d4d08243d2 100644 --- a/src/Symfony/Bundle/AsseticBundle/Command/DumpCommand.php +++ b/src/Symfony/Bundle/AsseticBundle/Command/DumpCommand.php @@ -33,7 +33,7 @@ class DumpCommand extends Command ->setName('assetic:dump') ->setDescription('Dumps all assets to the filesystem') ->addArgument('write_to', InputArgument::OPTIONAL, 'Override the configured asset root') - ->addOption('watch', null, InputOption::VALUE_NONE, 'Check for changes every second') + ->addOption('watch', null, InputOption::VALUE_NONE, 'Check for changes every second, debug mode only') ; } @@ -70,6 +70,10 @@ class DumpCommand extends Command */ protected function watch(LazyAssetManager $am, $basePath, OutputInterface $output, $debug = false) { + if (!$debug) { + throw new \RuntimeException('The --watch option is only available in debug mode.'); + } + $refl = new \ReflectionClass('Assetic\\AssetManager'); $prop = $refl->getProperty('assets'); $prop->setAccessible(true); @@ -92,9 +96,7 @@ class DumpCommand extends Command // reset the asset manager $prop->setValue($am, array()); - if ($debug) { - $am->load(); - } + $am->load(); file_put_contents($cache, serialize($previously)); $error = '';