Socket
Socket
Sign inDemoInstall

spawn-manager

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

spawn-manager

abstracts how you use spawn in node


Version published
Maintainers
1
Created
Source

#spawn-manager module

This module contains the SpawnManager class and the spawnEvents enum. This module facilitates the management of creating sub processes using spawn.

API Documentation

Classes

SpawnManager

This class abstracts the way you interact with spawn functionality in node by providing events which you can optionally listen to or you can just get the result of executing your command. Check return details of runCommand method

Constants

spawnEvents : enum

Enum representing the events that will be fired by the SpawnManager.

Typedefs

cmdResultCallback : function

Callback to be called after the command finish executing.

result : Object

SpawnManager

This class abstracts the way you interact with spawn functionality in node by providing events which you can optionally listen to or you can just get the result of executing your command. Check return details of runCommand method

Kind: global class

new SpawnManager()

create new SpawnManager

spawnManager.runCommand(cli, cmdArguments, cmdDir, cb)

execute a new command in a sub process (spawn). This class implements EventEmitter and fire certain events while executing the command. Please review spawnEvents for the list of emitted events

Kind: instance method of SpawnManager

ParamTypeDescription
clistringthe command name
cmdArgumentsArraycommand arguments
cmdDirstringpath to where the command will be executed. Pass null if you don't want to set it
cbcmdResultCallbackcallback function to be called after the command finish executing

Example

let manager = new SpawnManager();
let cmdOutput = '';
let exitCode;
manager.runCommand('ping', ['-c','4','localhost'], null, (err, result) => {
   // you can get the command exit code, stdout and stderr here in the result object
   exitCode = result.exitCode;
});
manager.on(SpawnManager.spawnEvents.stdoutChunk, (text) => {
   // you may want to subscribe to these events if you want to output the progress of a long running command for example but these subscription remains optional because you will get everything back in the result object
   cmdOutput += text;
});

spawnEvents : enum

Enum representing the events that will be fired by the SpawnManager.

Kind: global constant
Read only: true
Properties

NameTypeDefaultDescription
stdoutChunkstring"stdoutChunk"stdoutChunk represents a chunk of data returns from the command stdout
stderrChunkstring"stderrChunk"stderrChunk represents a chunk of data returns from the command stderr
errorstring"cmdError"error represents an error occurred while executing the command

cmdResultCallback : function

Callback to be called after the command finish executing.

Kind: global typedef

ParamTypeDescription
error*An object repenting an error.
theresultresult of executing the command

result : Object

Kind: global typedef
Properties

NameTypeDescription
stdoutValstringcommand stdout value
stderrValstringcommand stderr value
exitCodenumbercommand exit code

Keywords

FAQs

Package last updated on 27 Mar 2016

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc