FetchAssetsCommand::execute()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 11
nc 2
nop 2
1
<?php
2
3
namespace Victoire\Bundle\UIBundle\Command;
4
5
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
use Symfony\Component\Process\Exception\ProcessFailedException;
9
use Symfony\Component\Process\Process;
10
11
class FetchAssetsCommand extends ContainerAwareCommand
0 ignored issues
show
introduced by
Missing class doc comment
Loading history...
12
{
13
    /**
14
     * {@inheritdoc}
15
     */
16
    public function configure()
17
    {
18
        parent::configure();
19
20
        $this
21
            ->setName('victoire:ui:fetchAssets')
22
            ->setDescription('Fetch every assets (with bower)');
23
    }
24
25
    /**
26
     * @param InputInterface  $input
27
     * @param OutputInterface $output
28
     *
29
     * @return void
30
     */
31
    protected function execute(InputInterface $input, OutputInterface $output)
32
    {
33
        $output->writeln('<fg=white;bg=cyan;options=bold>Fetching Bower dependencies</>');
34
        $process = new Process('cd vendor/victoire/victoire/Bundle/UIBundle/Resources/config && bower install');
35
        try {
36
            $process->mustRun();
37
38
            echo $process->getOutput();
39
        } catch (ProcessFailedException $e) {
40
            $output->writeln(sprintf('<error>%s</error>', 'Did you installed bower properly ?'));
41
            $output->writeln(sprintf('<error>%s</error>', $e->getMessage()));
42
        }
43
44
        $output->writeln(sprintf('<info>%s</info>', $process->getOutput()));
45
        $output->writeln('✅  <fg=green>Ok</> Assets fetched');
46
    }
47
}
48