@iyowei/sweep-node-modules-cli 0.1.0 → 0.1.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/dist/cli.js CHANGED
@@ -682,6 +682,7 @@ import { accessSync, constants } from "node:fs";
682
682
  var DU_PROBES = ["/usr/bin/du", "/bin/du"];
683
683
  var hasControlChar = (target) => target.includes(`
684
684
  `) || target.includes("\r");
685
+ var PROG_PREFIX_RE = /^(?:\/[^\s:]*)?[a-z][a-z0-9_-]*:\s+/;
685
686
  function findDu(platform = process.platform) {
686
687
  if (platform === "win32")
687
688
  return null;
@@ -769,7 +770,15 @@ function describeDuFailure(detail) {
769
770
  return { reason: `读取失败 (${detail})`, missing: false };
770
771
  }
771
772
  function parseDuErrorLine(line) {
772
- const match = /^du:\s+(.+):\s+(.+)$/.exec(line);
773
+ const body = line.replace(PROG_PREFIX_RE, "");
774
+ const gnu = /^cannot\s+(?:access|read directory|stat|open)\s+'(.*)':\s+(.+)$/.exec(body);
775
+ if (gnu !== null) {
776
+ const path = gnu[1];
777
+ const detail = gnu[2];
778
+ if (path !== undefined && detail !== undefined)
779
+ return { path, detail };
780
+ }
781
+ const match = /^(.+):\s+(.+)$/.exec(body);
773
782
  if (match === null)
774
783
  return null;
775
784
  const path = match[1];
@@ -818,7 +827,7 @@ function createDuSizer(bin = findDu()) {
818
827
  continue;
819
828
  const errorLine = parseDuErrorLine(line);
820
829
  if (errorLine === null) {
821
- warnings.push(`体积统计失败 (未归因): ${line.trim()}`);
830
+ warnings.push(`体积统计失败 (未归因): ${line.replace(PROG_PREFIX_RE, "").trim()}`);
822
831
  continue;
823
832
  }
824
833
  const failure = describeDuFailure(errorLine.detail);
@@ -828,6 +837,8 @@ function createDuSizer(bin = findDu()) {
828
837
  }
829
838
  failures.set(errorLine.path, failure);
830
839
  }
840
+ for (const path of failures.keys())
841
+ sizes.delete(path);
831
842
  }
832
843
  for (const target of sorted) {
833
844
  if (hasControlChar(target)) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "commit": "bf77fe2fa62183d25329026e902a4dbe6d392ad2",
3
+ "commit": "2b0f7012154196efa2e5be20be89cc9484dbc374",
4
4
  "dirty": false,
5
- "cliSha256": "009da46c8aa9b57715aa25688e063afd7386fe978b150eb5dcb5bc6da4ee7795",
6
- "builtAt": "2026-09-29T03:42:59.276Z"
5
+ "cliSha256": "29d6844dca8fe28b8105b9704473ac1602ec7d081e8b813cd23db6ec1b80d61a",
6
+ "builtAt": "2026-09-29T05:40:51.133Z"
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iyowei/sweep-node-modules-cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "CLI to find and delete node_modules across projects: scan multiple workspace roots (monorepo friendly), bulk-remove them to free up disk space, preview first and delete after confirmation. 工作区级 node_modules 批量清理工具。",
5
5
  "keywords": [
6
6
  "cli",
@@ -57,7 +57,7 @@
57
57
  "registry": "https://registry.npmjs.org/"
58
58
  },
59
59
  "devDependencies": {
60
- "@iyowei/sweep-node-modules": "workspace:^"
60
+ "@iyowei/sweep-node-modules": "*"
61
61
  },
62
62
  "scripts": {
63
63
  "build": "bun build src/cli.ts --target=node --outfile=dist/cli.js && bun scripts/write-dist-manifest.ts",