drush-node

node.js wrapper for drush.

Usage no npm install needed!

<script type="module">
  import drushNode from 'https://cdn.skypack.dev/drush-node';
</script>

README

drush for node.js

This is a simple node.js wrapper for running drush commands.

To use:

var drush = require('drush');

drush.init().then(
  function () {
    drush.exec('updb')
      .then(
        function (res) {
          console.log(res);
        }
      );
  }
);

The module is built on top of promised-io and exec returns a promise object. Chaining commands can therefore be conveniently done as follows:

var group = require('promised-io/promise').all([
  drush.init(),
  drush.exec('updb'),
  drush.exec('fra'),
  drush.exec('cc all')
]);

group.then(function (res) {
  console.log(res.join("\r"));
});

You must call Drush.init() before executing other commands, but as long as the Drush object remains in scope you only need to call it once.

Advanced options

You may pass additional options to the underlaying exec commands by calling init with a hash of appropriate options:

drush.init({ maxBuffer: 256 * 1024 * 1024 })

Note: You may need to increase the buffer size for commands that return a lot of output.