Skip to content

Commit e9c571c

Browse files
committed
Case 27689; Added Grunt command
1 parent 6779afb commit e9c571c

File tree

3 files changed

+73
-0
lines changed

3 files changed

+73
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ e.g. https://raw.githubusercontent.com/dennisinteractive/drupal_console_commands
5151
- site:construct
5252
- drupal **site:npm**
5353
Runs NPM.
54+
- drupal **site:grunt**
55+
Runs Grunt.
5456
- drupal **site:compile**
5557
A chain that will call all the commands below:
5658
- site:compose

console.config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,6 @@ application:
2222
class: \DennisDigital\Drupal\Console\Command\SitePHPUnitSetupCommand
2323
'site:npm':
2424
class: \DennisDigital\Drupal\Console\Command\SiteNPMCommand
25+
'site:grunt':
26+
class: \DennisDigital\Drupal\Console\Command\SiteGruntCommand
2527
name: { }

src/Command/SiteGruntCommand.php

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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

Comments
 (0)