Created
January 2, 2019 21:56
-
-
Save maxjing/d2e3df642f08ff1bed08e6caf8210df4 to your computer and use it in GitHub Desktop.
clear all files of a folde
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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