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
Here is the solution:
// Wait for file to exist, checks every 2 seconds
function getFile(path, timeout) {
const timeout = setInterval(function() {
const file = path;
const fileExists = fs.existsSync(file);
console.log('Checking for: ', file);
console.log('Exists: ', fileExists);
if (fileExists) {
clearInterval(timeout);
}
}, timeout);
};