Make command or app restart. e.g. make electron/webpack... restart.
install
npm install make-it-restart --save-devcreate a restartor
const restart = require('make-it-restart')
let restartor = restart(command, env)command: it supports running commands directly which in./node_modules/.bin/, likenpm run.env: set environment variables with an object.
script.js
let count = 0
console.log(process.env.NODE_ENV)
setInterval(() => {
console.log(++count)
}, 500)index.js
const restart = require('make-it-restart')
let restartor = restart('node ./script.js', { NODE_ENV: 'production' })
restartor()
setInterval(() => {
restartor()
}, 2000)result
production
1
2
3
restarting...
production
1
2
3
restarting...