oh-my-node-modules 1.2.7 → 1.2.8

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
@@ -3005,12 +3005,27 @@ async function scanForNodeModules(options, onProgress) {
3005
3005
  }
3006
3006
  return result;
3007
3007
  }
3008
+ async function findRepoRoot(startPath) {
3009
+ let currentPath = startPath;
3010
+ const root = "/";
3011
+ while (currentPath !== root) {
3012
+ const gitPath = join2(currentPath, ".git");
3013
+ try {
3014
+ if (await fileExists(gitPath)) {
3015
+ return currentPath;
3016
+ }
3017
+ } catch {}
3018
+ currentPath = dirname(currentPath);
3019
+ }
3020
+ return startPath;
3021
+ }
3008
3022
  async function analyzeNodeModules(nodeModulesPath, projectPath) {
3009
3023
  const stats = await fs2.stat(nodeModulesPath);
3010
3024
  const { totalSize, packageCount, totalPackageCount } = await calculateDirectorySize(nodeModulesPath);
3011
3025
  const packageJson = await readPackageJson(projectPath);
3012
3026
  const projectName = packageJson?.name || basename(projectPath);
3013
3027
  const projectVersion = packageJson?.version;
3028
+ const repoPath = await findRepoRoot(projectPath);
3014
3029
  const sizeCategory = getSizeCategory(totalSize);
3015
3030
  const ageCategory = getAgeCategory(stats.mtime);
3016
3031
  return {
@@ -3018,6 +3033,7 @@ async function analyzeNodeModules(nodeModulesPath, projectPath) {
3018
3033
  projectPath,
3019
3034
  projectName,
3020
3035
  projectVersion,
3036
+ repoPath,
3021
3037
  sizeBytes: totalSize,
3022
3038
  sizeFormatted: formatBytes(totalSize),
3023
3039
  packageCount,
package/dist/index.js CHANGED
@@ -239,12 +239,27 @@ async function scanForNodeModules(options, onProgress) {
239
239
  }
240
240
  return result;
241
241
  }
242
+ async function findRepoRoot(startPath) {
243
+ let currentPath = startPath;
244
+ const root = "/";
245
+ while (currentPath !== root) {
246
+ const gitPath = join2(currentPath, ".git");
247
+ try {
248
+ if (await fileExists(gitPath)) {
249
+ return currentPath;
250
+ }
251
+ } catch {}
252
+ currentPath = dirname(currentPath);
253
+ }
254
+ return startPath;
255
+ }
242
256
  async function analyzeNodeModules(nodeModulesPath, projectPath) {
243
257
  const stats = await fs2.stat(nodeModulesPath);
244
258
  const { totalSize, packageCount, totalPackageCount } = await calculateDirectorySize(nodeModulesPath);
245
259
  const packageJson = await readPackageJson(projectPath);
246
260
  const projectName = packageJson?.name || basename(projectPath);
247
261
  const projectVersion = packageJson?.version;
262
+ const repoPath = await findRepoRoot(projectPath);
248
263
  const sizeCategory = getSizeCategory(totalSize);
249
264
  const ageCategory = getAgeCategory(stats.mtime);
250
265
  return {
@@ -252,6 +267,7 @@ async function analyzeNodeModules(nodeModulesPath, projectPath) {
252
267
  projectPath,
253
268
  projectName,
254
269
  projectVersion,
270
+ repoPath,
255
271
  sizeBytes: totalSize,
256
272
  sizeFormatted: formatBytes(totalSize),
257
273
  packageCount,
@@ -383,10 +399,12 @@ async function quickScan(rootPath) {
383
399
  const projectPath = currentPath;
384
400
  const nodeModulesPath = join2(currentPath, "node_modules");
385
401
  const packageJson = await readPackageJson(projectPath);
402
+ const repoPath = await findRepoRoot(projectPath);
386
403
  results.push({
387
404
  path: nodeModulesPath,
388
405
  projectPath,
389
- projectName: packageJson?.name || basename(projectPath)
406
+ projectName: packageJson?.name || basename(projectPath),
407
+ repoPath
390
408
  });
391
409
  }
392
410
  for (const entry of entries) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oh-my-node-modules",
3
- "version": "1.2.7",
3
+ "version": "1.2.8",
4
4
  "description": "Visualize, analyze, and clean up node_modules directories to reclaim disk space",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",