yawn

0.1.1 • Public • Published

yawn build status

Super small wrapper around Node.js child_process.spawn, pretty boring actually.

yawn

var yawn = require('yawn');
 
yawn('ls', [ '-la' ], { trackStdout: true } , function (err, res) {
  if (err) return console.error(err);
  // res is a Buffer
  console.log('Result', res.toString());    
})
Result total 48
drwxr-xr-x   11 thlorenz  staff   374 Aug 27 20:27 .
drwxr-xr-x  105 thlorenz  staff  3570 Aug 27 20:15 ..
drwxr-xr-x   13 thlorenz  staff   442 Aug 27 20:16 .git
-rw-r--r--    1 thlorenz  staff    97 Aug 27 20:16 .gitignore
-rw-r--r--    1 thlorenz  staff    48 Aug 27 20:16 .travis.yml
-rw-r--r--    1 thlorenz  staff  1078 Aug 27 20:16 LICENSE
-rw-r--r--    1 thlorenz  staff   318 Aug 27 20:54 README.md
-rw-r--r--    1 thlorenz  staff  1896 Aug 27 20:54 index.js
drwxr-xr-x    4 thlorenz  staff   136 Aug 27 20:27 node_modules
-rw-r--r--    1 thlorenz  staff   774 Aug 27 20:17 package.json
drwxr-xr-x    3 thlorenz  staff   102 Aug 27 20:16 test

Installation

npm install yawn

API

yawn(command, argv, opts, cb) → {Object}

Runs the given command with the provided options.

WARNING: when trackStdout is set, the output of the process is buffered which may lead to large amount of memory usage

Parameters:
Name Type Description
command string

command to run, i.e. ls

argv Array.<string>

arguments to pass to child_process.spawn, i.e. -la

opts Object

options passed to child_process.spawn

Properties
Name Type Description
trackStderr boolean

if true, the given callback is invoked with an error whenever any output into stderr is encountered (default: false)

trackStdout boolean

if true, the given callback is invoked with the data piped to stdout as a Buffer when the process is finished (default: false)

cb function

(optional), if supplied it is invoked when processed finished

Source:
Returns:

the spawned process

Type
Object

generated with docme

License

MIT

Package Sidebar

Install

npm i yawn

Weekly Downloads

13

Version

0.1.1

License

MIT

Last publish

Collaborators

  • thlorenz