readdirSync throws errors if the path doesn't exist. Let's make sure the path exists before calling it.
fs.js:808
return binding.readdir(pathModule._makeLong(path));
at Error (native)
at Object.fs.readdirSync (fs.js:808:18)
at module.exports.cb (/app/node_modules/metalsmith-prismic-server/src/remove-old-dirs.js:13:6)
^
at null._repeat (/app/node_modules/metalsmith-prismic-server/src/prod-server.js:91:7)
Error: ENOENT: no such file or directory, scandir '/app/builds/preview'
at wrapper [as _onTimeout] (timers.js:275:19)
...
Also, added a cleanupInterval option so one can configure how frequently the cleanups occur independently of the preview expiration age.
readdirSync
throws errors if the path doesn't exist. Let's make sure the path exists before calling it.Also, added a
cleanupInterval
option so one can configure how frequently the cleanups occur independently of the preview expiration age.