1.0.1 • Published 7 years ago

promise-exit v1.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

promise-exit

Run process.exit() after a promise function has completed.

Installation

npm install promise-exit --save-dev

Usage

const exit = require('promise-exit')

function main() {
  return Promise.resolve('Hello World!')
}

if (require.main === module) {
  exit(main)

  // custom error exit code, default to `1`
  exit(main, { errorCode: 255 })

  // do not print traceback, default to `true`
  exit(main, { trace: false })

  // pass arguments to function
  exit(main(process.argv))
}