# grunt-drupal-delegate

> Delegate Grunt commands to Drupal extensions

Latest version **1.0.1** (published 2022-07-19) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install grunt-drupal-delegate
pnpm add grunt-drupal-delegate
yarn add grunt-drupal-delegate
bun add grunt-drupal-delegate
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2022-07-19 |
| First published | 2022-05-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=14 |
| Dependencies | 2 |
| Unpacked size | 12.8 KB |
| Known vulnerabilities | 0 (+5 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Ambient.Impact |
| Maintainers | ambient.impact |
| Keywords | gruntplugin, drupal, shell, command, cmd, exec, spawn, child, process, cli |

## Links

- npm: https://www.npmjs.com/package/grunt-drupal-delegate
- Repository: https://github.com/Ambient-Impact/grunt-drupal-delegate
- Issues: https://github.com/Ambient-Impact/grunt-drupal-delegate/issues
- npm.io page: https://npm.io/package/grunt-drupal-delegate

## Dependencies (2)

- [semver](https://npm.io/package/semver.md) ^7.3.7
- [shescape](https://npm.io/package/shescape.md) ^1.5.4

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2022-07-19
- 1.0.0 — 2022-05-23

## README

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`](https://github.com/sindresorhus/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:

```javascript
require('grunt-drupal-delegate')(grunt);
```

And that's it - [any tasks](https://gruntjs.com/creating-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](https://gruntjs.com/creating-tasks#multi-tasks) defined in that Drupal
extension's gruntfile.

## Examples

* `grunt my_module:sass` - Invoke the `sass` task defined in `my_module`'s gruntfile.

* `grunt my_theme:sass:header` - Invoke the `sass:header` multi task defined in `my_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

* A working [Drupal](https://www.drupal.org/) installation

* [Drush](https://www.drush.org/) 9 or newer

* [Grunt](https://gruntjs.com/) 1.5 or newer

* [Node.js](https://nodejs.org/) 14 or newer

----

# Questions and answers

* Set up everything correctly but getting `Unable to decode output into JSON: Syntax error` on Windows? This was a [known issue](https://github.com/consolidation/site-process/issues/56) fixed in [Drush 11.0.6](https://github.com/drush-ops/drush/releases/tag/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](https://www.npmjs.com/package/fraud) seems like a good solution as a file system cache.

* Options to enable or disable output like [`grunt-shell`](https://github.com/sindresorhus/grunt-shell#options) has.

----

# Credits

* [semver](https://www.npmjs.com/package/semver) is used to compare semantic version strings for Drush detection.

* [Shescape](https://www.npmjs.com/package/shescape) is used to escape shell characters in the delegated commands to prevent arbitrary shell execution. Recommended that you use it in your own projects whenever executing shell commands containing user input.

---
_Source: https://npm.io/package/grunt-drupal-delegate · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
