clear_node_modules 1.2.9 → 1.3.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/README.md +13 -3
- package/package.json +1 -1
- package/src/lib.js +3 -3
package/README.md
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
<details open>
|
|
2
|
+
<summary><strong>English</strong></summary>
|
|
3
|
+
<br>
|
|
4
|
+
|
|
5
|
+
# clear_node_modules
|
|
2
6
|
|
|
3
7
|
A command-line tool to delete all `node_modules` directories within a specified path.
|
|
4
8
|
|
|
@@ -49,9 +53,13 @@ cnm <path> [limit]
|
|
|
49
53
|
|
|
50
54
|
MIT
|
|
51
55
|
|
|
52
|
-
|
|
56
|
+
</details>
|
|
57
|
+
|
|
58
|
+
<details>
|
|
59
|
+
<summary><strong>中文 (Chinese)</strong></summary>
|
|
60
|
+
<br>
|
|
53
61
|
|
|
54
|
-
# clear_node_modules
|
|
62
|
+
# clear_node_modules
|
|
55
63
|
|
|
56
64
|
一个用于清理指定路径下所有 `node_modules` 目录的命令行工具。
|
|
57
65
|
|
|
@@ -101,3 +109,5 @@ cnm <path> [limit]
|
|
|
101
109
|
## 许可证
|
|
102
110
|
|
|
103
111
|
MIT
|
|
112
|
+
|
|
113
|
+
</details>
|
package/package.json
CHANGED
package/src/lib.js
CHANGED
|
@@ -53,12 +53,12 @@ function wrap(LIMIT_SIZE, NODE_MODULES) {
|
|
|
53
53
|
const entries = fs.readdirSync(currentPath);
|
|
54
54
|
if (entries.length === 0) return;
|
|
55
55
|
|
|
56
|
-
const dirSize = getDirSize(currentPath);
|
|
57
|
-
if (dirSize / 1024 < LIMIT_SIZE) return;
|
|
58
|
-
|
|
59
56
|
for (const entry of entries) {
|
|
60
57
|
const subPath = path.join(currentPath, entry);
|
|
61
58
|
if (entry === NODE_MODULES && fs.statSync(subPath).isDirectory()) {
|
|
59
|
+
const dirSize = getDirSize(subPath);
|
|
60
|
+
if (dirSize / 1024 / 1024 < LIMIT_SIZE) continue;
|
|
61
|
+
|
|
62
62
|
const spinner = ora(
|
|
63
63
|
`(${++doneCount}/${totalCount}) Removing ${subPath}`
|
|
64
64
|
).start();
|