update,
This commit is contained in:
25
task1/_poc/clear_node_module.js
Normal file
25
task1/_poc/clear_node_module.js
Normal file
@@ -0,0 +1,25 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
function removeNodeModules(dir) {
|
||||
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
||||
|
||||
for (const entry of entries) {
|
||||
const fullPath = path.join(dir, entry.name);
|
||||
|
||||
if (entry.isDirectory()) {
|
||||
if (["node_modules", ".next"].includes(entry.name)) {
|
||||
fs.rmSync(fullPath, { recursive: true });
|
||||
} else {
|
||||
removeNodeModules(fullPath);
|
||||
}
|
||||
|
||||
if ([".apk", ".log", ".tmp"].some((ext) => entry.name.endsWith(ext))) {
|
||||
fs.unlinkSync(fullPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
removeNodeModules(".");
|
||||
console.log("directories have been removed.");
|
Reference in New Issue
Block a user