node-modules-tools 1.4.2 → 2.0.0-beta.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/dist/index.mjs CHANGED
@@ -106,7 +106,7 @@ function populateRawResult(input) {
106
106
  return result;
107
107
  }
108
108
 
109
- function analyzeExports(exports$1, depth = 0) {
109
+ function analyzeExports(exports, depth = 0) {
110
110
  const result = {
111
111
  hasImport: false,
112
112
  hasRequire: false,
@@ -114,22 +114,22 @@ function analyzeExports(exports$1, depth = 0) {
114
114
  };
115
115
  if (depth > 10)
116
116
  return result;
117
- if (exports$1 == null)
117
+ if (exports == null)
118
118
  return result;
119
- if (typeof exports$1 === "string") {
120
- if (exports$1.endsWith(".mjs") || exports$1.endsWith(".mts"))
119
+ if (typeof exports === "string") {
120
+ if (exports.endsWith(".mjs") || exports.endsWith(".mts"))
121
121
  result.hasImport = true;
122
- else if (exports$1.endsWith(".cjs") || exports$1.endsWith(".cts"))
122
+ else if (exports.endsWith(".cjs") || exports.endsWith(".cts"))
123
123
  result.hasRequire = true;
124
124
  return result;
125
125
  }
126
- if (Array.isArray(exports$1)) {
127
- for (const item of exports$1)
126
+ if (Array.isArray(exports)) {
127
+ for (const item of exports)
128
128
  mergeAnalysis(result, analyzeExports(item, depth + 1));
129
129
  return result;
130
130
  }
131
- if (typeof exports$1 === "object") {
132
- for (const [key, value] of Object.entries(exports$1)) {
131
+ if (typeof exports === "object") {
132
+ for (const [key, value] of Object.entries(exports)) {
133
133
  if (key === "import")
134
134
  result.hasImport = true;
135
135
  else if (key === "require")
@@ -188,7 +188,7 @@ async function getPackageInstallSize(pkg) {
188
188
  return;
189
189
  if (pkg.name.startsWith("#"))
190
190
  return;
191
- if (pkg.version.match(/^(?:file|link|workspace):/))
191
+ if (/^(?:file|link|workspace):/.test(pkg.version))
192
192
  return;
193
193
  if (!pkg.filepath)
194
194
  return;
@@ -199,7 +199,7 @@ async function getPackageInstallSize(pkg) {
199
199
  if (n.isFile()) {
200
200
  files.push(join(dir, n.name));
201
201
  } else if (n.isDirectory()) {
202
- if (n.name.match(/^\.|^node_modules$/))
202
+ if (/^\.|^node_modules$/.test(n.name))
203
203
  continue;
204
204
  await traverse(join(dir, n.name));
205
205
  }
@@ -241,35 +241,35 @@ function guessFileCategory(file) {
241
241
  return "other";
242
242
  if (dirs.some((d) => d.match(/^(?:bin|binary)$/)))
243
243
  return "bin";
244
- if (base.match(/\.(?:test|tests|spec|specs)\.\w+$/i))
244
+ if (/\.(?:test|tests|spec|specs)\.\w+$/i.test(base))
245
245
  return "test";
246
- if (base.match(/\.map$/i))
246
+ if (/\.map$/i.test(base))
247
247
  return "map";
248
- if (base.match(/\.d(\.\w+)?\.[cm]?tsx?$/i))
248
+ if (/\.d(?:\.\w+)?\.[cm]?tsx?$/i.test(base))
249
249
  return "dts";
250
- if (base.match(/\.exe$/i))
250
+ if (/\.exe$/i.test(base))
251
251
  return "bin";
252
- if (base.match(/\.(?:css|scss|sass|less)$/i))
252
+ if (/\.(?:css|scss|sass|less)$/i.test(base))
253
253
  return "css";
254
- if (base.match(/\.(?:json[c5]?|ya?ml)$/i))
254
+ if (/\.(?:json[c5]?|ya?ml)$/i.test(base))
255
255
  return "json";
256
- if (base.match(/\.html?$/i))
256
+ if (/\.html?$/i.test(base))
257
257
  return "html";
258
- if (base.match(/\.[cm]?jsx?$/i))
258
+ if (/\.[cm]?jsx?$/i.test(base))
259
259
  return "js";
260
- if (base.match(/\.[cm]?tsx?$/i))
260
+ if (/\.[cm]?tsx?$/i.test(base))
261
261
  return "ts";
262
- if (base.match(/\.(?:vue|svelte|astro)$/i))
262
+ if (/\.(?:vue|svelte|astro)$/i.test(base))
263
263
  return "comp";
264
- if (base.match(/\.(?:png|jpe?g|gif|svg)$/i))
264
+ if (/\.(?:png|jpe?g|gif|svg)$/i.test(base))
265
265
  return "image";
266
- if (base.match(/\.(?:md|txt|mdx|markdown|rst)$/i))
266
+ if (/\.(?:md|txt|mdx|markdown|rst)$/i.test(base))
267
267
  return "doc";
268
- if (base.match(/\.(?:wasm|wat)$/i))
268
+ if (/\.(?:wasm|wat)$/i.test(base))
269
269
  return "wasm";
270
- if (base.match(/\.flow$/i))
270
+ if (/\.flow$/i.test(base))
271
271
  return "flow";
272
- if (base.match(/\.(?:ttf|otf|woff2?)$/i))
272
+ if (/\.(?:ttf|otf|woff2?)$/i.test(base))
273
273
  return "font";
274
274
  return "other";
275
275
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "node-modules-tools",
3
3
  "type": "module",
4
- "version": "1.4.2",
4
+ "version": "2.0.0-beta.2",
5
5
  "description": "Tools for inspecting node_modules",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -31,17 +31,17 @@
31
31
  "p-limit": "^7.3.0",
32
32
  "package-manager-detector": "^1.6.0",
33
33
  "pathe": "^2.0.3",
34
- "pkg-types": "^2.3.0",
35
- "publint": "^0.3.18",
34
+ "pkg-types": "^2.3.1",
35
+ "publint": "^0.3.19",
36
36
  "semver": "^7.7.4",
37
- "tinyexec": "^1.0.2"
37
+ "tinyexec": "^1.1.2"
38
38
  },
39
39
  "devDependencies": {
40
- "@pnpm/list": "^1000.3.2",
40
+ "@pnpm/list": "^1000.3.4",
41
41
  "@pnpm/types": "^1001.3.0",
42
42
  "@types/js-yaml": "^4.0.9",
43
43
  "@types/stream-json": "^1.7.8",
44
- "stream-json": "^1.9.1",
44
+ "stream-json": "^2.1.0",
45
45
  "unbuild": "^3.6.1"
46
46
  },
47
47
  "scripts": {