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

ez-spawn

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ez-spawn

Simple, consistent sync or async process spawning

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.9K
decreased by-20.64%
Maintainers
1
Weekly downloads
 
Created
Source

EZ-Spawn

Simple, consistent sync/async process spawning

Build Status Windows Build Status

Dependencies Coverage Status Codacy Score Inline docs

npm License

Features

  • Normalizes the results of spawn and spawnSync calls through the async and sync functions that ez-spawn provides.

  • Normalizes the arguments passed into the spawn and spawnSync

  • Both return the same process object no matter how it is called.

  • Tested on Mac, Linux, and Windows as well as Node v4-7

Example

let sync = require('ez-spawn').sync;
let async = require('ez-spawn').async;

// Make a synchronous call
let process = sync('ls', '-al');

//Make an asynchronous call that accepts a callback
async('ls', '-a' '-l', (process) => {
  console.log(process.status);
  //Etc...
});

//Make an asynchronous call that returns a promise
async('ls -al')
  .then((process) => {
    console.log(process.stdout);
    //Etc...
  })
  .catch((err) => {
    //Etc...
  })

Installation

Node

Install using npm:

npm install ez-spawn

Then require it in your code:

let async = require("ez-spawn").async;
let sync = require("ez-spawn").sync;

API

sync(command, [arguments], [options])

Synchronously spawns a process and returns a Process object

  • command - The command string to be executed.
  • arguments - (optional) An array or a series of individual string parameters that are the arguments to be associated with the command parameter.
  • options - (optional) The spawnSync options object.

async(command, [arguments], [options], callback?)

Asynchronously spawns a process and returns a promise or a callback if specified that contains a Process object.

  • command - The command string to be executed.
  • arguments - (optional) An array or a series of individual string parameters that are the arguments to be associated with the command parameter.
  • options - (optional) The spawnSync options object.
  • callback - (optional) If a callback is not specified then spawned process results are returned as a Promise

Process

Both async and sync both return a Process object that contains the following properties. It mirrors the object returned by spawnSync.

  • command - The command that was used to spawn the process.
  • args - The command-line arguments that were passed to the process.
  • pid - The numeric process ID assigned by the operating system.
  • stdout - The process's standard output.
  • stderr - The process's error output.
  • output - All program output [stdin, stdout, stderr].
  • exitCode - The process's exit code.
  • signal - The signal used to kill the process, if applicable.
  • error - The error that occurred while spawning or killing the process, if any.
  • toString() - Returns the full command and arguments used to spawn the process.

Contributing

We welcome any contributions, enhancements, and bug-fixes. File an issue on GitHub and submit a pull request.

Building/Testing

To build/test the project locally on your computer:

  1. Clone this repo
    git clone hhttps://github.com/rkrauskopf/ez-spawn.git

  2. Install dependencies
    npm install

  3. Run the tests
    npm test

License

ez-spawn is 100% free and open-source, under the MIT license. Use it however you want.

Keywords

FAQs

Package last updated on 04 Feb 2017

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