Socket
Socket
Sign inDemoInstall

spawn-command

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

spawn-command

Spawn commands like `child_process.exec` does but return a `ChildProcess`


Version published
Maintainers
1
Created

What is spawn-command?

The spawn-command npm package is a simple wrapper around the child_process.spawn function from Node.js. It allows you to spawn shell commands with ease, handling the intricacies of different operating system command line interfaces. It is particularly useful for running shell commands within Node.js applications.

What are spawn-command's main functionalities?

Spawning shell commands

This feature allows you to spawn a shell command and listen to its output. The example shows how to spawn an 'echo' command and log its output to the console.

const spawnCommand = require('spawn-command');
const child = spawnCommand('echo Hello World');
child.stdout.on('data', function (data) {
  console.log('stdout: ' + data);
});

Handling command completion

This feature allows you to handle the completion of a shell command. The example demonstrates how to spawn a 'ls -la' command and log the exit code once the command completes.

const spawnCommand = require('spawn-command');
const child = spawnCommand('ls -la');
child.on('close', function (code) {
  console.log('child process exited with code ' + code);
});

Other packages similar to spawn-command

FAQs

Package last updated on 06 Nov 2012

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