@noahnu/unused-files 0.2.1 → 0.2.2
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/CHANGELOG.md +6 -0
- package/lib/api/index.js +8 -6
- package/lib/api/walkDependencyTree.js +2 -0
- package/lib/command.js +17 -7
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/lib/api/index.js
CHANGED
@@ -50,12 +50,14 @@ async function findUnusedFiles({ entryFiles, ignorePatterns = ['**/node_modules'
|
|
50
50
|
unvisitedFiles.delete(resolvedDependency);
|
51
51
|
}
|
52
52
|
}
|
53
|
+
const unused = Array.from(unvisitedFiles.intersection(files))
|
54
|
+
.map((abspath) => node_path_1.default.relative(cwd, abspath))
|
55
|
+
.sort();
|
56
|
+
const used = Array.from(visitedFiles.intersection(files))
|
57
|
+
.map((abspath) => node_path_1.default.relative(cwd, abspath))
|
58
|
+
.sort();
|
53
59
|
return {
|
54
|
-
unused
|
55
|
-
|
56
|
-
.sort(),
|
57
|
-
used: Array.from(visitedFiles)
|
58
|
-
.map((abspath) => node_path_1.default.relative(cwd, abspath))
|
59
|
-
.sort(),
|
60
|
+
unused,
|
61
|
+
used,
|
60
62
|
};
|
61
63
|
}
|
@@ -18,6 +18,8 @@ async function* walkDependencyTree(source, { resolvers, visited, depth = DEFAULT
|
|
18
18
|
debug(`${source}: Unknown file extension '${ext}' [skipping]`);
|
19
19
|
return;
|
20
20
|
}
|
21
|
+
// Convert to realpath if possible
|
22
|
+
source = await node_fs_1.default.promises.realpath(source).catch(() => source);
|
21
23
|
const visitedSet = visited ?? new Set();
|
22
24
|
if (visitedSet.has(source))
|
23
25
|
return;
|
package/lib/command.js
CHANGED
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
15
15
|
}) : function(o, v) {
|
16
16
|
o["default"] = v;
|
17
17
|
});
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
};
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
19
|
+
var ownKeys = function(o) {
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
21
|
+
var ar = [];
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
23
|
+
return ar;
|
24
|
+
};
|
25
|
+
return ownKeys(o);
|
26
|
+
};
|
27
|
+
return function (mod) {
|
28
|
+
if (mod && mod.__esModule) return mod;
|
29
|
+
var result = {};
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
31
|
+
__setModuleDefault(result, mod);
|
32
|
+
return result;
|
33
|
+
};
|
34
|
+
})();
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
26
36
|
exports.BaseCommand = void 0;
|
27
37
|
const clipanion_1 = require("clipanion");
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@noahnu/unused-files",
|
3
|
-
"version": "0.2.
|
3
|
+
"version": "0.2.2",
|
4
4
|
"repository": {
|
5
5
|
"type": "git",
|
6
6
|
"url": "https://github.com/noahnu/nodejs-tools.git",
|
@@ -43,7 +43,7 @@
|
|
43
43
|
"@noahnu/internal-test-utils": "0.0.0",
|
44
44
|
"@types/micromatch": "^4.0.9",
|
45
45
|
"@types/node": "^22.9.0",
|
46
|
-
"typescript": "^5.
|
46
|
+
"typescript": "^5.7.2"
|
47
47
|
},
|
48
48
|
"types": "./lib/api/index.d.ts"
|
49
49
|
}
|