|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * @file |
| 5 | + * Contains \DennisDigital\Drupal\Console\Command\SiteGruntCommand. |
| 6 | + * |
| 7 | + * Runs Grunt. |
| 8 | + */ |
| 9 | + |
| 10 | +namespace DennisDigital\Drupal\Console\Command; |
| 11 | + |
| 12 | +use Symfony\Component\Console\Input\InputInterface; |
| 13 | +use Symfony\Component\Console\Output\OutputInterface; |
| 14 | +use DennisDigital\Drupal\Console\Exception\SiteCommandException; |
| 15 | + |
| 16 | +/** |
| 17 | + * Class SiteGruntCommand |
| 18 | + * |
| 19 | + * @package DennisDigital\Drupal\Console\Command |
| 20 | + */ |
| 21 | +class SiteGruntCommand extends SiteBaseCommand { |
| 22 | + |
| 23 | + /** |
| 24 | + * {@inheritdoc} |
| 25 | + */ |
| 26 | + protected function configure() { |
| 27 | + parent::configure(); |
| 28 | + |
| 29 | + $this->setName('site:grunt') |
| 30 | + ->setDescription('Runs Grunt.'); |
| 31 | + } |
| 32 | + |
| 33 | + /** |
| 34 | + * {@inheritdoc} |
| 35 | + */ |
| 36 | + protected function interact(InputInterface $input, OutputInterface $output) { |
| 37 | + parent::interact($input, $output); |
| 38 | + |
| 39 | + } |
| 40 | + |
| 41 | + /** |
| 42 | + * {@inheritdoc} |
| 43 | + */ |
| 44 | + protected function execute(InputInterface $input, OutputInterface $output) { |
| 45 | + parent::execute($input, $output); |
| 46 | + |
| 47 | + $this->io->comment(sprintf('Running Grunt on %s', |
| 48 | + $this->destination |
| 49 | + )); |
| 50 | + |
| 51 | + $command = sprintf( |
| 52 | + 'cd %sweb && ' . |
| 53 | + 'find . -type d \( -name node_modules -o -name contrib -o -path ./core \) -prune -o -name Gruntfile.js -execdir sh -c "grunt" \;', |
| 54 | + $this->shellPath($this->destination) |
| 55 | + ); |
| 56 | + |
| 57 | + // Run. |
| 58 | + $shellProcess = $this->getShellProcess(); |
| 59 | + |
| 60 | + if ($shellProcess->exec($command, TRUE)) { |
| 61 | + $this->io->writeln($shellProcess->getOutput()); |
| 62 | + $this->io->success('Grunt job completed'); |
| 63 | + } |
| 64 | + else { |
| 65 | + throw new SiteCommandException($shellProcess->getOutput()); |
| 66 | + } |
| 67 | + } |
| 68 | + |
| 69 | +} |
0 commit comments