Socket
Book a DemoInstallSign in
Socket

observable-process

Package Overview
Dependencies
Maintainers
2
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

observable-process

High-level support for spawning, observing, and interacting with child processes in Node.js

Source
npmnpm
Version
0.3.0
Version published
Weekly downloads
57
39.02%
Maintainers
2
Weekly downloads
 
Created
Source

Node.js Child Process Observer

Circle CI Dependency Status devDependency Status

A high-level API for spawning child processes in Node.js and waiting until they output a certain text.

ObservableProcess = require('observable-process');

observer = new ObservableProcess('my-server --port 3000');
observer.wait('listening on port 3000', function() {
  // the child process says it is ready now
});

More details around waiting for output of spawned processes in the spec and its implementation.

Logging the output

  • by default the output of the observed process is hidden
  • provide the option verbose: true to log the output on stdio
  • provide custom console streams via the option console
observer = new ObservableProcess('my-server', { verbose: true });
// output goes to your terminal

observer = new ObservableProcess('my-server', { verbose: true, console: myConsole });
// output goes to your myConsole object

More details around logging options in the spec and its implementation.

Killing the process

If the process is running, you can kill it via:

observer.kill()

To let ObservableProcess notify you when a process ended, provide it a callback via the onExit parameter:

observer = new ObservableProcess('my-server', onExit: function() {
  // here the server has ended/crashed
});
  • nexpect: Allows to define expectations on command output, and send it input, but doesn't allow to add more listeners to existing long-running processes, which makes declarative testing hard.

FAQs

Package last updated on 06 Jan 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