use of path.join everywhere

This commit is contained in:
Clément GOUIN
2019-06-20 10:40:48 +02:00
parent fe6cca6453
commit 07dd06a338
8 changed files with 77 additions and 76 deletions
+7 -6
View File
@@ -1,15 +1,16 @@
const fs = require('fs');
const path = require('path');
const deleteFolderSync = (path) => {
if (!fs.existsSync(path))
const deleteFolderSync = (dir) => {
if (!fs.existsSync(dir))
return;
fs.readdirSync(path, {withFileTypes: true}).forEach((item) => {
fs.readdirSync(dir, {withFileTypes: true}).forEach((item) => {
if (item.isDirectory())
deleteFolderSync(`${path}/${item.name}`);
deleteFolderSync(path.join(dir,item.name));
else
fs.unlinkSync(`${path}/${item.name}`);
fs.unlinkSync(path.join(dir,item.name));
});
fs.rmdirSync(path);
fs.rmdirSync(dir);
};
module.exports = {