You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

command_runner

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

command_runner

Run system commands and return a Promise.

1.2.0
latest
Source
npm
Version published
Weekly downloads
17
30.77%
Maintainers
1
Weekly downloads
 
Created
Source

Command Runner

Node.js module for running system commands and returning a Promise.

NPM

Summary

command_runner simply adds some Promise wrappers around the standard Node.js .exec() and .spawn() functions in the child_process module. The API is basically unchanged, but there are some changes in the implementation:

.exec()

Example:

var CR = require('command_runner');
CR.exec('ls -al').then(function (res) {
    console.log('exitCode: %i', res.exitCode); // 0
    console.log('exitSignal: %s', res.exitSignal); // null
    console.log('stdout: %s', res.stdout); // dir listing ....
    console.log('stderr: %s', res.stderr); // empty string
    console.log('errorMessage: %s', res.errorMessage); // undefined
});

command_runner.exec() always sets the exitCode and exitSignal, even if there is no error (to 0 and null, respectively), where the native Node.js child_process.exec() does not set them unless there is an error.

.spawn()

Example: Running the same command above, in a different way. The important distinction is that a shell is not invoked with spawn().

var CR = require('command_runner');
CR.spawn('ls', ['a', 'l']).then(function (res) {
    console.log('exitCode: %i', res.exitCode); // 0
    console.log('exitSignal: %s', res.exitSignal); // null
    console.log('stdout: %s', res.stdout); // dir listing ....
    console.log('stderr: %s', res.stderr); // empty string
    console.log('errorMessage: %s', res.errorMessage); // undefined
});

Unlike the native Node.js child_process.spawn(), command_runner.spawn() buffers stdout and stderr streams, and then resolves the promise with the results after the 'close' event is fired from the child process.

Copyright: (c) 2015 by Kris Walker kris@kixx.name (http://www.kixx.name/)

Unless otherwise indicated, all source code is licensed under the MIT license. See MIT-LICENSE for details.

Keywords

command

FAQs

Package last updated on 06 Apr 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts