You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
monaco-editor/scripts/rmdir.js

22 lines
503 B
JavaScript

const fs = require('fs');
const path = require('path');
const target = path.join(process.cwd(), process.argv[2]);
rmDir(target);
console.log(`Deleted ${process.argv[2]}`);
function rmDir(dirPath) {
let entries = fs.readdirSync(dirPath);
if (entries.length > 0) {
for (var i = 0; i < entries.length; i++) {
var filePath = path.join(dirPath, entries[i]);
if (fs.statSync(filePath).isFile()) {
fs.unlinkSync(filePath);
} else {
rmDir(filePath);
}
}
}
fs.rmdirSync(dirPath);
}