Skip to content

Instantly share code, notes, and snippets.

@danielgospodinow
Created July 13, 2019 13:24
Show Gist options
  • Save danielgospodinow/39d1f01713701021fe3bb077a758f124 to your computer and use it in GitHub Desktop.
Save danielgospodinow/39d1f01713701021fe3bb077a758f124 to your computer and use it in GitHub Desktop.
Screentopia - cleanup images function
function cleanupImages(imageDirectory, imageDirectoryCapacity) {
const images = fs.readdirSync(imageDirectory);
if (images.length >= imageDirectoryCapacity) {
console.log("Cleaning up space ...");
fs.unlinkSync(imageDirectory + "/" + images.pop());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment