Skip to content
This repository has been archived by the owner on Jan 7, 2024. It is now read-only.

Commit

Permalink
Added script to run update in loop
Browse files Browse the repository at this point in the history
  • Loading branch information
EpicDataInfo committed Jul 3, 2020
1 parent 3460b50 commit 2f2b9b1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"description": "",
"main": "index.js",
"scripts": {
"update": "node update"
"update": "node update",
"loop": "node update-loop"
},
"author": {
"name": "Szymon Lisowiec",
Expand Down
23 changes: 23 additions & 0 deletions update-loop.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const ChildProcess = require('child_process');

function sleep (time) {
return new Promise((resolve) => {
const sto = setTimeout(() => {
clearTimeout(sto);
resolve();
}, time);
});
}

function run () {
let invoked = false;
const process = ChildProcess.fork(`${__dirname}/update.js`);
process.on('exit', async () => {
if (invoked) return;
invoked = true;
await sleep(1000);
run();
});
}

run();

0 comments on commit 2f2b9b1

Please sign in to comment.