What is the best way to delete several files in node.js?
function deleteFiles(files, callback){
...
}
var files = [\'file1.js\', \'file2.jpg\', \'file3.css\
Best way is delete files synchronously into a loop using unlinkSync(path)
function (see the doc), from node v7.6.0
so far.
Syntax is provided below:
// myListOfFiles will be your list of files with paths relative to your script.
myListOfFiles.forEach(filePath => {
fs.unlinkSync(filePath);
return;
});
A reference here