Socket
Socket
Sign inDemoInstall

await-spawn

Package Overview
Dependencies
9
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    await-spawn

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


Version published
Weekly downloads
9.2K
decreased by-43.8%
Maintainers
1
Install size
348 kB
Created
Weekly downloads
 

Readme

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

FAQs

Last updated on 16 Apr 2021

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