easy-spawn

Utilities that make it easier to write child_process.spawn programmes.

Usage no npm install needed!

<script type="module">
  import easySpawn from 'https://cdn.skypack.dev/easy-spawn';
</script>

README

easy-spawn

Utilities that make it easier to write child_process.spawn programmes.

Features

  • Easy to use
  • Standard callback with err and data

Usage

Below are some examples of how to work with easy-spawn, you can find more examples under the /test/ directory

Get file list with ls

var Spawn = require('easy-spawn');

spawn = new Spawn({
    cwd: '/working directory where you want to ran command',
});

spawn.cmd('ls', function(err, data) {
   console.log(data); 
});

spawn.cmd(['ls', '-l', '/var/log'], function(err, data) {
    console.log(data);
});

Get your git version

var Spawn = require('easy-spawn');

spawn = new Spawn();
spawn.cmd(['git', '--version'], function(err, data) {
   console.log(data); // git version 1.7.xxx 
});

Installation

npm install easy-spawn