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
fs.watch() API is what you need.
Be sure to read all the caveats mentioned there before you use it.