exec-then

Child process execute with promise, deferred

Usage no npm install needed!

<script type="module">
  import execThen from 'https://cdn.skypack.dev/exec-then';
</script>

README

NPM version"> Build Status Dependency Status

Child process execute with promise, deferred

Install

$ npm install --save exec-then

Usage

var exec = require('exec-then');

exec('pwd').then(function(res) {
  assert(res.stdout.indexOf(path.resolve(__dirname, '../')) !== -1);
}, function(err) {
  console.log(err.toString());
  assert(false);
});

exec(['ls', '-al'], function(std, deferred) {
  if (std.stdout.indexOf('test') === -1) {
    return deferred.reject();
  }
  return true;
}).then(function(res) {
  if (res) {
    console.log('You have test file');
  }
}, function() {
  console.log('Where am I?');
});

Options

exec-node using same options to Child Process options except to options below.

  • verbose: show stdio/stderr message while child process is running. if verbose set true? child_process.spawn will be executed.

License

MIT © ragingwind