grunt-drupal-delegate v1.0.1
Grunt plug-in to run Grunt tasks defined in Drupal extensions (modules, themes, install profiles) from the Drupal root.
This is inspired by
grunt-shell
, which is
recommended for more general-purpose shell execution.
Installation
npm install --save-dev grunt-drupal-delegate
Then, in your project root's gruntfile:
require('grunt-drupal-delegate')(grunt);
And that's it - any tasks defined in Drupal extensions that Drush can find can now be invoked from the Drupal root.
Usage
From your Drupal root directory, invoke grunt drupal_extension:task
, where
drupal_extension
is the machine name of the Drupal extesion you want to run
tasks for, with anything after the first :
the name of a task or multi
task defined in that Drupal
extension's gruntfile.
Examples
grunt my_module:sass
- Invoke thesass
task defined inmy_module
's gruntfile.grunt my_theme:sass:header
- Invoke thesass:header
multi task defined inmy_theme
's gruntfile.grunt my_module:sass my_theme:sass:header
- Do both of the above with a single command.grunt my_module:sass my_theme:sass my_theme:uglify
- Also supports more than one task per Drupal extension.
Requirements
Questions and answers
- Set up everything correctly but getting
Unable to decode output into JSON: Syntax error
on Windows? This was a known issue fixed in Drush 11.0.6.
Planned improvements
Caching of Drupal extension names and their local paths so that Drush does not need to be invoked every time. Ideally this would be stored in a temporary file that's only rebuilt when the Drupal cache is rebuilt and/or extensions enabled/disabled. The Fraud package seems like a good solution as a file system cache.
Options to enable or disable output like
grunt-shell
has.