Skip to content
This repository has been archived by the owner on Feb 7, 2023. It is now read-only.

Latest commit

 

History

History
28 lines (20 loc) · 977 Bytes

README.md

File metadata and controls

28 lines (20 loc) · 977 Bytes

@npmcli/exec

THIS REPOSITORY IS DEPRECATED AND ARCHIVED, THE MODULE HERE WAS NEVER PUBLISHED. SEE @npmcli/promise-spawn

This is the module that the npm CLI team uses to run child processes, with our use cases and conventions.

It does a few things beyond child_process.spawn(), namely:

  • Returns a Promise, thanks to @npmcli/promise-spawn
  • When running as root, infers a uid and gid to run as based on the current working directory
  • Forwards signals to children processes, once for background processes, and until the child exits for foreground ones.
  • Automatically prepends node_modules/.bin directories to the PATH environment variable

Usage

const exec = require('@npmcli/exec')

exec('some command', ['with', 'args'], { and: 'options' }, { also: 'extras' })
  .then((result) => {
    // do something with the result
  })
  .catch((err) => {
    // process exited via signal or non-0 exit code
  })