yawn
Super small wrapper around Node.js child_process.spawn, pretty boring actually.
Last updated 6 years ago by thlorenz .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install yawn 
SYNC missed versions from official npm registry.

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

Current Tags

  • 0.1.1                                ...           latest (6 years ago)

2 Versions

  • 0.1.1                                ...           6 years ago
  • 0.1.0                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 3
Dependencies (0)
None
Dev Dependencies (1)
Dependents (2)

Copyright 2014 - 2016 © taobao.org |