mirror of
https://github.com/idrawjs/idraw
synced 2026-05-24 10:08:34 +00:00
26 lines
No EOL
597 B
JavaScript
26 lines
No EOL
597 B
JavaScript
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
function removeFullDir(dirPath) {
|
|
let files = [];
|
|
if (fs.existsSync(dirPath)) {
|
|
files = fs.readdirSync(dirPath);
|
|
files.forEach((filename) => {
|
|
let curPath = path.join(dirPath, filename);
|
|
const stat = fs.statSync(curPath);
|
|
if(stat.isDirectory()) {
|
|
removeFullDir(curPath);
|
|
} else if (stat.isFile()) {
|
|
// fs.unlinkSync(curPath);
|
|
fs.rmSync(curPath);
|
|
} else {
|
|
fs.unlinkSync(curPath);
|
|
}
|
|
});
|
|
fs.rmdirSync(dirPath);
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
removeFullDir,
|
|
} |