Socket
Socket
Sign inDemoInstall

spawn-command

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

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
Weekly downloads
4.4M
increased by2.85%
Maintainers
1
Install size
4.88 kB
Created
Weekly downloads
 

Package description

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

Readme

Source

spawn-command Build Status

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

Installation

npm install spawn-command

Usage

var spawnCommand = require('spawn-command'),
    child = spawnCommand('echo "Hello spawn" | base64');

child.stdout.on('data', function (data) {
  console.log('data', data);
});

child.on('exit', function (exitCode) {
  console.log('exit', exitCode);
});

FAQs

Last updated on 09 Oct 2014

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc