try-exec

1.1.4 • Public • Published

Exec an npm script, .bin command, or other CLI commands from nodejs,
trying x times in case a condition doesn't meets

Install

npm install -D try-exec

# or

yarn add --dev try-exec

Usage

const tryExec = require('try-exec')
const isReachable = require('is-reachable')

tryExec({
  script: 'gatsby develop',
  // Check if API is reachable
  check: async () => await isReachable('cdn.contentful.com'),
})

API

tryExec(?options)

Options

max

Max attemps to check

type: Number

default: 3

interval

Delay between each attemp

type: Number (ms)

default: 1500

script

CLI script to run

type: String

default: echo "Hello World"

check

(Async) function to run when checking

type: Function

default: () => false

verbose

Log when attemps, number of each iteration and results. Could be passed a string to log.

type: Boolean|String

default: false

Readme

Keywords

none

Package Sidebar

Install

npm i try-exec

Weekly Downloads

2

Version

1.1.4

License

MIT

Unpacked Size

3.14 kB

Total Files

3

Last publish

Collaborators

  • elrumordelaluz