I\'m generating files automatically, and I have another script which will check if a given file is already generated, so how could I implement such a function:
f
function holdBeforeFileExists(filePath, timeout) {
timeout = timeout < 1000 ? 1000 : timeout;
return new Promise((resolve)=>{
var timer = setTimeout(function () {
resolve();
},timeout);
var inter = setInterval(function () {
if(fs.existsSync(filePath) && fs.lstatSync(filePath).isFile()){
clearInterval(inter);
clearTimeout(timer);
resolve();
}
}, 100);
});
}