Socket
Socket
Sign inDemoInstall

@jsdevtools/ez-spawn

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jsdevtools/ez-spawn

Simple, consistent sync or async process spawning


Version published
Maintainers
2
Created

What is @jsdevtools/ez-spawn?

@jsdevtools/ez-spawn is an npm package that simplifies the process of spawning child processes in Node.js. It provides a straightforward API for running shell commands and handling their output, errors, and exit codes.

What are @jsdevtools/ez-spawn's main functionalities?

Running Shell Commands

This feature allows you to run shell commands and capture their output. The example demonstrates running the 'echo' command and logging its output.

const { spawn } = require('@jsdevtools/ez-spawn');

spawn('echo', ['Hello, World!'])
  .then(result => {
    console.log(result.stdout); // Outputs: Hello, World!
  })
  .catch(err => {
    console.error(err);
  });

Handling Errors

This feature allows you to handle errors that occur when running shell commands. The example demonstrates attempting to run a nonexistent command and catching the resulting error.

const { spawn } = require('@jsdevtools/ez-spawn');

spawn('nonexistent-command')
  .then(result => {
    console.log(result.stdout);
  })
  .catch(err => {
    console.error('Command failed:', err.message);
  });

Capturing Exit Codes

This feature allows you to capture the exit code of a shell command. The example demonstrates running a Node.js script that exits with code 1 and logging the exit code.

const { spawn } = require('@jsdevtools/ez-spawn');

spawn('node', ['-e', 'process.exit(1)'])
  .then(result => {
    console.log('Exit code:', result.exitCode); // Outputs: Exit code: 1
  })
  .catch(err => {
    console.error(err);
  });

Other packages similar to @jsdevtools/ez-spawn

Keywords

FAQs

Package last updated on 16 Jul 2020

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