mirror of
https://github.com/amark/gun.git
synced 2025-03-30 15:08:33 +00:00
18 lines
476 B
JavaScript
18 lines
476 B
JavaScript
var fs = require('fs');
|
|
var nodePath = require('path');
|
|
|
|
var dir = __dirname + '/../';
|
|
|
|
module.exports = function rm(path, full) {
|
|
path = full || nodePath.join(dir, path);
|
|
if(!fs.existsSync(path)){ return }
|
|
fs.readdirSync(path).forEach(function(file,index){
|
|
var curPath = path + "/" + file;
|
|
if(fs.lstatSync(curPath).isDirectory()) { // recurse
|
|
rm(null, curPath);
|
|
} else { // delete file
|
|
fs.unlinkSync(curPath);
|
|
}
|
|
});
|
|
fs.rmdirSync(path);
|
|
}; |