Skip to content

Instantly share code, notes, and snippets.

@maxjing
Created January 2, 2019 21:56
Show Gist options
  • Save maxjing/d2e3df642f08ff1bed08e6caf8210df4 to your computer and use it in GitHub Desktop.
Save maxjing/d2e3df642f08ff1bed08e6caf8210df4 to your computer and use it in GitHub Desktop.
clear all files of a folde
const clearFolder = directory => {
fs.readdir(directory, (err, files) => {
if (err) throw err;
for (const file of files) {
fs.unlink(path.join(directory, file), err => {
if (err) throw err;
});
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment