Is possible to restart automatically a node cli script when it's finished to execute the code?
I have this cli script that will run until a variable reach a limit
const maxExecution = 200;
let i = 0;
let task = setInterval( () => {
i++;
if( i >= maxExecution ){
clearInterval(task);
}
// code here...
},5000);
This code will work fine and will stop the tasks when the i
variable reach the set limit. I'm reading this question about how to manage process.exit
. Is there any event I can listen to understand if the script execution have reached the end?