-
Notifications
You must be signed in to change notification settings - Fork 2
/
clean.js
34 lines (30 loc) · 979 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
32
33
34
var fs = require('fs');
var ncp = require('ncp').ncp;
function removeFile(file) {
fs.unlink(file, function (err) {
if (err) return console.log(err);
console.log('Cleaning: deleted file ' + file + '.');
});
}
function deleteFolderRecursive(path) {
if( fs.existsSync(path) ) {
fs.readdirSync(path).forEach(function(file,index) {
var curPath = path + "/" + file;
if(fs.statSync(curPath).isDirectory()) { // recurse
deleteFolderRecursive(curPath);
} else { // delete file
fs.unlinkSync(curPath);
}
});
fs.rmdirSync(path);
}
};
ncp("node_modules/coffeebone", ".", function (err) {
if (err) {
return console.error(err);
}
console.log('Coffeebone successfully moved.');
deleteFolderRecursive('./node_modules/coffeebone');
console.log('Cleaning: deleted folder ' + './node_modules/coffeebone' + '.');
removeFile('./clean.js');
});