clear_node_modules 1.3.1 → 1.4.1
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.js +24 -17
- package/package.json +5 -7
- package/config.json +0 -5
package/bin.js
CHANGED
|
@@ -1,39 +1,46 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
const path = require("path");
|
|
4
|
-
const config = require("./config.json");
|
|
5
4
|
const clearDir = require("./src/lib");
|
|
6
5
|
|
|
7
6
|
const { version } = require("./package.json");
|
|
8
7
|
|
|
9
8
|
const args = process.argv.slice(2);
|
|
10
9
|
|
|
10
|
+
// 版本信息
|
|
11
11
|
if (args.includes("-v") || args.includes("--version")) {
|
|
12
12
|
console.log(`cnm v${version}`);
|
|
13
13
|
process.exit(0);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
// 帮助信息
|
|
17
|
+
const isHelp = args.some((arg) => /^(-+|\/)(h(elp)?|\?)$/.test(arg));
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
if (isHelp) {
|
|
20
|
+
console.log(`
|
|
21
|
+
cnm v${version} - Clear Node Modules
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
Usage: npx clear_node_modules [path] [limit] [folder]
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
Arguments:
|
|
26
|
+
path Target directory (default: current directory)
|
|
27
|
+
limit Minimum size in MB to delete (default: 0)
|
|
28
|
+
folder Folder name to delete (default: node_modules)
|
|
27
29
|
|
|
28
|
-
|
|
30
|
+
Examples:
|
|
31
|
+
npx clear_node_modules # Clear all node_modules in current dir
|
|
32
|
+
npx clear_node_modules ./projects # Clear in specific directory
|
|
33
|
+
npx clear_node_modules ./ 100 # Only delete if > 100MB
|
|
29
34
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
log(" delete the specified folder!");
|
|
35
|
-
log("");
|
|
36
|
-
process.exit(1);
|
|
35
|
+
After global install (npm i -g clear_node_modules):
|
|
36
|
+
cnm # Same as above, shorter command
|
|
37
|
+
`);
|
|
38
|
+
process.exit(0);
|
|
37
39
|
}
|
|
38
40
|
|
|
41
|
+
// 默认配置
|
|
42
|
+
const DIST_DIR = path.resolve(process.cwd(), args[0] || "./");
|
|
43
|
+
const LIMIT_SIZE = args[1] || 0;
|
|
44
|
+
const NODE_MODULES = args[2] || "node_modules";
|
|
45
|
+
|
|
39
46
|
clearDir(DIST_DIR, LIMIT_SIZE, NODE_MODULES);
|
package/package.json
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clear_node_modules",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.4.1",
|
|
4
|
+
"description": "Recursively remove node_modules folders from current directory and subdirectories",
|
|
5
5
|
"main": "index.js",
|
|
6
|
-
"directories": {
|
|
7
|
-
"test": "test"
|
|
8
|
-
},
|
|
9
6
|
"bin": {
|
|
10
7
|
"cnm": "./bin.js"
|
|
11
8
|
},
|
|
@@ -18,7 +15,9 @@
|
|
|
18
15
|
},
|
|
19
16
|
"keywords": [
|
|
20
17
|
"clear",
|
|
21
|
-
"node_modules"
|
|
18
|
+
"node_modules",
|
|
19
|
+
"cleanup",
|
|
20
|
+
"npx"
|
|
22
21
|
],
|
|
23
22
|
"author": "taobeer",
|
|
24
23
|
"license": "ISC",
|
|
@@ -27,7 +26,6 @@
|
|
|
27
26
|
},
|
|
28
27
|
"homepage": "https://github.com/mooniitt/clear_node_modules#readme",
|
|
29
28
|
"dependencies": {
|
|
30
|
-
"clear_node_modules": "^1.2.0",
|
|
31
29
|
"ora": "^3.0.0",
|
|
32
30
|
"rimraf": "^2.6.2"
|
|
33
31
|
}
|