clear_node_modules 1.2.7 → 1.2.9
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/README.md +92 -10
- package/bin.js +5 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,21 +1,103 @@
|
|
|
1
|
-
# clear_node_modules
|
|
1
|
+
# clear_node_modules (English)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A command-line tool to delete all `node_modules` directories within a specified path.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Recursively finds and deletes all `node_modules` folders.
|
|
8
|
+
- Allows setting a size limit to only delete `node_modules` larger than a certain size.
|
|
9
|
+
- Simple and easy-to-use command-line interface.
|
|
8
10
|
|
|
9
|
-
##
|
|
11
|
+
## Installation
|
|
10
12
|
|
|
13
|
+
```bash
|
|
14
|
+
npm install clear_node_modules -g
|
|
11
15
|
```
|
|
12
|
-
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
cnm <path> [limit]
|
|
13
21
|
```
|
|
14
22
|
|
|
15
|
-
|
|
23
|
+
### Arguments
|
|
24
|
+
|
|
25
|
+
- `path`: The directory path to clean up (required).
|
|
26
|
+
- `limit`: The size limit in MB. Only `node_modules` directories larger than this size will be deleted (optional).
|
|
27
|
+
|
|
28
|
+
### Examples
|
|
29
|
+
|
|
30
|
+
1. Delete all `node_modules` in the current directory:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
cnm .
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
2. Delete all `node_modules` in a specific directory:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
cnm /path/to/your/projects
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
3. Delete all `node_modules` larger than 100MB in a specific directory:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
cnm /path/to/your/projects 100
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## License
|
|
49
|
+
|
|
50
|
+
MIT
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
# clear_node_modules (中文)
|
|
16
55
|
|
|
17
|
-
|
|
56
|
+
一个用于清理指定路径下所有 `node_modules` 目录的命令行工具。
|
|
18
57
|
|
|
58
|
+
## 功能特点
|
|
59
|
+
|
|
60
|
+
- 递归查找并删除所有 `node_modules` 文件夹。
|
|
61
|
+
- 支持设置大小限制,只删除大于特定大小的 `node_modules`。
|
|
62
|
+
- 简单易用的命令行界面。
|
|
63
|
+
|
|
64
|
+
## 安装
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
npm install clear_node_modules -g
|
|
19
68
|
```
|
|
20
|
-
|
|
69
|
+
|
|
70
|
+
## 使用方法
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
cnm <path> [limit]
|
|
21
74
|
```
|
|
75
|
+
|
|
76
|
+
### 参数说明
|
|
77
|
+
|
|
78
|
+
- `path`: 要清理的目录路径 (必需)。
|
|
79
|
+
- `limit`: 文件大小限制 (单位 MB)。只有大于此大小的 `node_modules` 目录才会被删除 (可选)。
|
|
80
|
+
|
|
81
|
+
### 使用示例
|
|
82
|
+
|
|
83
|
+
1. 删除当前目录下的所有 `node_modules`:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
cnm .
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
2. 删除指定目录下的所有 `node_modules`:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
cnm /path/to/your/projects
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
3. 删除指定目录下所有大于 100MB 的 `node_modules`:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
cnm /path/to/your/projects 100
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## 许可证
|
|
102
|
+
|
|
103
|
+
MIT
|
package/bin.js
CHANGED
|
@@ -15,17 +15,17 @@ if (args.includes("-v") || args.includes("--version")) {
|
|
|
15
15
|
|
|
16
16
|
const log = console.log;
|
|
17
17
|
|
|
18
|
-
const DIST_DIR = path.resolve(
|
|
19
|
-
const LIMIT_SIZE =
|
|
20
|
-
const NODE_MODULES =
|
|
18
|
+
const DIST_DIR = path.resolve(process.cwd(), args[0] || config.dist_dir_path);
|
|
19
|
+
const LIMIT_SIZE = args[1] || config.dist_dir_size;
|
|
20
|
+
const NODE_MODULES = args[2] || config.dist_dir_name;
|
|
21
21
|
|
|
22
22
|
let isHelp = false;
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
args.forEach((arg) => {
|
|
25
25
|
if (arg.match(/^(-+|\/)(h(elp)?|\?)$/)) isHelp = true;
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
-
if (
|
|
28
|
+
if (args.length < 1) isHelp = true;
|
|
29
29
|
|
|
30
30
|
if (isHelp) {
|
|
31
31
|
log("");
|