I am trying to follow the instructions here to create a script that prints something every 5 minutes. But it's not working: when I call upon it using node scripts.js alive
it gives no output what so ever and just opens a new line in the terminal. What am I doing wrong?
const program = require('commander');
program.command('alive').action(async function() {
console.log("testttt");
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
};
for (let i = 0; i <= 36; i++) {
await sleep(300000);
console.log(i);
};
process.exit(0);
});
I have also tried, with the same result:
for (let i = 0; i <= 36; i++) {
await sleep(300000).then(async function(response) {
console.log(i);
});
};