README
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