forked from the-bugging/react-use-downloader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclean.js
31 lines (25 loc) · 764 Bytes
/
clean.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* eslint-disable no-unused-vars */
/* eslint-env node */
"use strict";
var fs = require("fs");
function deleteFolderRecursive(path) {
if (fs.existsSync(path) && fs.lstatSync(path).isDirectory()) {
fs.readdirSync(path).forEach(function (file, index) {
var curPath = path + "/" + file;
if (fs.lstatSync(curPath).isDirectory()) {
// recurse
deleteFolderRecursive(curPath);
} else {
// delete file
fs.unlinkSync(curPath);
}
});
console.log(`Deleting directory "${path}"...`);
fs.rmdirSync(path);
}
}
console.log("Cleaning working tree...");
process.argv.forEach(function (val, index, array) {
deleteFolderRecursive("./" + val);
});
console.log("Successfully cleaned working tree!");