Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

await-spawn

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

await-spawn

> `child_process.spawn()` wrapped in a `Promise` for doing async/await.

latest
Source
npmnpm
Version
4.0.2
Version published
Weekly downloads
10K
-9.13%
Maintainers
1
Weekly downloads
 
Created
Source

await-spawn

child_process.spawn() wrapped in a Promise for doing async/await.

npm Node version Build Status JavaScript Style Guide

Install

$ npm i await-spawn -S

Usage

const spawn = require('await-spawn')

const main = async () => {
  try {
    const bl = await spawn('ls', ['-al'])
    console.log(bl.toString())
  } catch (e) {
    console.log(e.stderr.toString())
  }
}

main()

Api

Exposes a single function, which has the same api as child_process.spawn().

Returns a Promise with .child set to the spawned child process. The Promise resolves to the buffered output of child.stdout in the form of a BufferList object.

If there was an error, the Promise rejects with an Error object, which has the following extra properties:

  • code the error code
  • stdout the buffered output of stdout in the form of a BufferList object
  • stderr the buffered output of stderr in the form of a BufferList object

Note that child.stdout doesn't exist if options.stdio === 'inherit', so the Promise resolves to ''.

License

MIT

Keywords

await

FAQs

Package last updated on 16 Apr 2021

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