Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nodeproc

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

nodeproc

Simpler handling of spawning processes

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

nodeproc

Simpler way to handle spawning processes in NodeJs

var Nodeproc = require('nodeproc');

var processes = new Nodeproc();

// Most basic use
processes.spawn('npm ls').then(function(results) {
  console.log('Finished');
  console.log('Process ID: ', results.procId);
  console.log('Exit code: ', results.exitCode);
});

// Slightly more complicated
processes.spawn({
  command: 'npm',
  args: ['ls'],
  cwd: '/home/joe' // Specify where the command should be run from
}).then(function() {
  console.log('Finished');
});

// Control stdout and/or stderr from the process.
// These can be anything that supports the write(data, encoding) method.
// These default to process.stdout and process.stderr respectively
var captureStdout = {
  write: function(data, encoding) {
    console.log('Got data: ', data.toString(encoding));
  }
};
processes.spawn({
  command: 'npm',
  args: 'ls' // Can either be an array or a space-delimited string
  stdout: captureStdout
}).then(funnction() {
  console.log('Finished');
});

// Catch errors using a Promise catch function
processes.spawn({
  command: 'npm',
  args: ['doesnotexit'],
  ignoreExitCode: true
}).catch(function(err) {
  console.log('Got error! ', err);
  console.log('Process ID: ', err.procId);
  console.log('Exit code: ', err.exitCode);
  console.log('Stderr: ', err.stderr);
});

// Can ignore error exit status codes, and always resolve the process
processes.spawn({
  command: 'npm',
  args: ['doesnotexit'],
  ignoreExitStatusCode: true
}).then(function() {
  console.log('Finished');
});

See the tests for more examples

FAQs

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

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