rm-node-m 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/index.js +34 -0
- package/package.json +15 -0
package/bin/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
|
|
6
|
+
let numberFilesDeletes = 0
|
|
7
|
+
|
|
8
|
+
function removeNodeModules(dir) {
|
|
9
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
10
|
+
|
|
11
|
+
for (const entry of entries) {
|
|
12
|
+
const fullPath = path.join(dir, entry.name);
|
|
13
|
+
|
|
14
|
+
if (entry.isDirectory()) {
|
|
15
|
+
if (entry.name === "node_modules") {
|
|
16
|
+
console.log(` Removing: ${fullPath}`);
|
|
17
|
+
fs.rmSync(fullPath, { recursive: true, force: true });
|
|
18
|
+
numberFilesDeletes++
|
|
19
|
+
} else {
|
|
20
|
+
removeNodeModules(fullPath);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Start from current directory
|
|
27
|
+
removeNodeModules(process.cwd());
|
|
28
|
+
if(numberFilesDeletes){
|
|
29
|
+
console.log("Done removing node_modules");
|
|
30
|
+
console.log(`Number of files deleted: ${numberFilesDeletes}`)
|
|
31
|
+
}
|
|
32
|
+
else{
|
|
33
|
+
console.log('No node_modules was found')
|
|
34
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "rm-node-m",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
7
|
+
},
|
|
8
|
+
"keywords": [],
|
|
9
|
+
"author": "",
|
|
10
|
+
"bin": {
|
|
11
|
+
"del_nodem": "bin/index.js"
|
|
12
|
+
},
|
|
13
|
+
"license": "MIT"
|
|
14
|
+
}
|
|
15
|
+
|