@socketsecurity/lib 5.2.1 → 5.4.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.
Files changed (60) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/bin.d.ts +0 -9
  3. package/dist/bin.js +70 -48
  4. package/dist/constants/agents.js +2 -2
  5. package/dist/constants/platform.d.ts +21 -0
  6. package/dist/constants/platform.js +30 -6
  7. package/dist/cover/code.js +13 -5
  8. package/dist/debug.js +1 -1
  9. package/dist/dlx/binary.d.ts +1 -1
  10. package/dist/dlx/binary.js +49 -39
  11. package/dist/dlx/cache.js +10 -2
  12. package/dist/dlx/dir.js +1 -1
  13. package/dist/dlx/manifest.d.ts +2 -1
  14. package/dist/dlx/manifest.js +45 -41
  15. package/dist/dlx/package.js +39 -19
  16. package/dist/dlx/packages.js +1 -1
  17. package/dist/dlx/paths.js +1 -1
  18. package/dist/env/rewire.js +10 -2
  19. package/dist/external/@inquirer/checkbox.js +4 -2528
  20. package/dist/external/@inquirer/confirm.js +4 -2371
  21. package/dist/external/@inquirer/input.js +4 -2395
  22. package/dist/external/@inquirer/password.js +4 -2503
  23. package/dist/external/@inquirer/search.js +4 -2500
  24. package/dist/external/@inquirer/select.js +4 -2617
  25. package/dist/external/del.js +4 -7139
  26. package/dist/external/fast-glob.js +4 -5776
  27. package/dist/external/inquirer-pack.js +4610 -0
  28. package/dist/external/npm-core.js +3 -1
  29. package/dist/external/pico-pack.js +7162 -0
  30. package/dist/external/picomatch.js +4 -1523
  31. package/dist/external/spdx-correct.js +4 -1384
  32. package/dist/external/spdx-expression-parse.js +4 -1047
  33. package/dist/external/spdx-pack.js +1640 -0
  34. package/dist/external/validate-npm-package-name.js +4 -104
  35. package/dist/fs.js +3 -3
  36. package/dist/git.js +41 -38
  37. package/dist/http-request.js +12 -4
  38. package/dist/ipc.js +53 -29
  39. package/dist/json/edit.js +1 -1
  40. package/dist/json/format.js +1 -1
  41. package/dist/logger.js +1 -1
  42. package/dist/packages/edit.js +3 -3
  43. package/dist/packages/isolation.js +45 -23
  44. package/dist/packages/licenses.js +10 -2
  45. package/dist/paths/normalize.js +3 -3
  46. package/dist/paths/packages.js +1 -1
  47. package/dist/paths/socket.d.ts +2 -2
  48. package/dist/paths/socket.js +27 -21
  49. package/dist/process-lock.js +23 -14
  50. package/dist/promises.js +1 -1
  51. package/dist/releases/github.d.ts +82 -137
  52. package/dist/releases/github.js +91 -48
  53. package/dist/releases/socket-btm.d.ts +78 -192
  54. package/dist/releases/socket-btm.js +112 -50
  55. package/dist/signal-exit.js +1 -1
  56. package/dist/spawn.js +11 -4
  57. package/dist/stdio/mask.d.ts +6 -21
  58. package/dist/stdio/mask.js +18 -14
  59. package/dist/themes/context.js +10 -2
  60. package/package.json +3 -2
package/CHANGELOG.md CHANGED
@@ -5,6 +5,36 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [5.4.0](https://github.com/SocketDev/socket-lib/releases/tag/v5.4.0) - 2026-01-07
9
+
10
+ ### Added
11
+
12
+ - **releases/github**: Extended release functions to accept glob patterns for asset discovery
13
+ - `getReleaseAssetUrl()` now accepts glob patterns: `'yoga-sync-*.mjs'`, `'models-*.tar.gz'`
14
+ - `downloadReleaseAsset()` now accepts glob patterns for automatic asset discovery
15
+ - `getLatestRelease()` now accepts asset patterns to find releases with matching assets
16
+ - Supports wildcards, brace expansion, RegExp patterns, and prefix/suffix objects
17
+ - Uses picomatch for robust glob pattern matching
18
+
19
+ - **releases/socket-btm**: Extended `downloadSocketBtmRelease()` to accept glob patterns
20
+ - `asset` parameter now accepts wildcards: `'yoga-sync-*.mjs'`, `'models-*.tar.gz'`
21
+ - Automatically discovers and downloads latest matching asset
22
+ - Eliminates need for hardcoded asset names in build scripts
23
+
24
+ ## [5.3.0](https://github.com/SocketDev/socket-lib/releases/tag/v5.3.0) - 2026-01-07
25
+
26
+ ### Added
27
+
28
+ - **releases/socket-btm**: Exported helper functions for external use
29
+ - `detectLibc()`: Detect musl vs glibc on Linux systems
30
+ - `getBinaryAssetName()`: Get GitHub asset name for platform/arch
31
+ - `getBinaryName()`: Get binary filename with platform-appropriate extension
32
+ - `getPlatformArch()`: Get platform-arch identifier for directory structure
33
+
34
+ - **releases/github**: Exported `getAuthHeaders()` for GitHub API authentication
35
+ - Returns headers with `Accept`, `X-GitHub-Api-Version`, and optional `Authorization`
36
+ - Checks `GH_TOKEN` and `GITHUB_TOKEN` environment variables
37
+
8
38
  ## [5.2.1](https://github.com/SocketDev/socket-lib/releases/tag/v5.2.1) - 2026-01-06
9
39
 
10
40
  ### Fixed
package/dist/bin.d.ts CHANGED
@@ -1,9 +1,3 @@
1
- // ============================================================================
2
- // Private Helper Functions
3
- // ============================================================================
4
- // ============================================================================
5
- // Types and Interfaces
6
- // ============================================================================
7
1
  /**
8
2
  * Options for the which function.
9
3
  */
@@ -21,9 +15,6 @@ export interface WhichOptions {
21
15
  /** Current working directory for resolving relative paths. */
22
16
  cwd?: string | undefined;
23
17
  }
24
- // ============================================================================
25
- // Public API (alphabetically sorted)
26
- // ============================================================================
27
18
  /**
28
19
  * Execute a binary with the given arguments.
29
20
  */
package/dist/bin.js CHANGED
@@ -42,8 +42,6 @@ __export(bin_exports, {
42
42
  whichSync: () => whichSync
43
43
  });
44
44
  module.exports = __toCommonJS(bin_exports);
45
- var import_node_fs = __toESM(require("node:fs"));
46
- var import_node_path = __toESM(require("node:path"));
47
45
  var import_home = require("./env/home");
48
46
  var import_windows = require("./env/windows");
49
47
  var import_xdg = require("./env/xdg");
@@ -52,6 +50,22 @@ var import_which = __toESM(require("./external/which"));
52
50
  var import_fs = require("./fs");
53
51
  var import_normalize = require("./paths/normalize");
54
52
  var import_spawn = require("./spawn");
53
+ let _fs;
54
+ // @__NO_SIDE_EFFECTS__
55
+ function getFs() {
56
+ if (_fs === void 0) {
57
+ _fs = require("fs");
58
+ }
59
+ return _fs;
60
+ }
61
+ let _path;
62
+ // @__NO_SIDE_EFFECTS__
63
+ function getPath() {
64
+ if (_path === void 0) {
65
+ _path = require("path");
66
+ }
67
+ return _path;
68
+ }
55
69
  // @__NO_SIDE_EFFECTS__
56
70
  async function execBin(binPath, args, options) {
57
71
  const resolvedPath = (0, import_normalize.isPath)(binPath) ? /* @__PURE__ */ resolveRealBinSync(binPath) : await whichReal(binPath);
@@ -77,19 +91,21 @@ To resolve:
77
91
  });
78
92
  }
79
93
  function findRealBin(binName, commonPaths = []) {
94
+ const fs = /* @__PURE__ */ getFs();
95
+ const path = /* @__PURE__ */ getPath();
80
96
  for (const binPath2 of commonPaths) {
81
- if (import_node_fs.default.existsSync(binPath2)) {
97
+ if (fs.existsSync(binPath2)) {
82
98
  return binPath2;
83
99
  }
84
100
  }
85
101
  const binPath = import_which.default.sync(binName, { nothrow: true });
86
102
  if (binPath) {
87
- const binDir = import_node_path.default.dirname(binPath);
103
+ const binDir = path.dirname(binPath);
88
104
  if (isShadowBinPath(binDir)) {
89
105
  const allPaths = import_which.default.sync(binName, { all: true, nothrow: true }) || [];
90
106
  const pathsArray = Array.isArray(allPaths) ? allPaths : typeof allPaths === "string" ? [allPaths] : [];
91
107
  for (const altPath of pathsArray) {
92
- const altDir = import_node_path.default.dirname(altPath);
108
+ const altDir = path.dirname(altPath);
93
109
  if (!isShadowBinPath(altDir)) {
94
110
  return altPath;
95
111
  }
@@ -100,49 +116,53 @@ function findRealBin(binName, commonPaths = []) {
100
116
  return void 0;
101
117
  }
102
118
  function findRealNpm() {
103
- const nodeDir = import_node_path.default.dirname(process.execPath);
104
- const npmInNodeDir = import_node_path.default.join(nodeDir, "npm");
105
- if (import_node_fs.default.existsSync(npmInNodeDir)) {
119
+ const fs = /* @__PURE__ */ getFs();
120
+ const path = /* @__PURE__ */ getPath();
121
+ const nodeDir = path.dirname(process.execPath);
122
+ const npmInNodeDir = path.join(nodeDir, "npm");
123
+ if (fs.existsSync(npmInNodeDir)) {
106
124
  return npmInNodeDir;
107
125
  }
108
126
  const commonPaths = ["/usr/local/bin/npm", "/usr/bin/npm"];
109
127
  const result = findRealBin("npm", commonPaths);
110
- if (result && import_node_fs.default.existsSync(result)) {
128
+ if (result && fs.existsSync(result)) {
111
129
  return result;
112
130
  }
113
131
  const npmPath = whichRealSync("npm", { nothrow: true });
114
- if (npmPath && typeof npmPath === "string" && import_node_fs.default.existsSync(npmPath)) {
132
+ if (npmPath && typeof npmPath === "string" && fs.existsSync(npmPath)) {
115
133
  return npmPath;
116
134
  }
117
135
  return "npm";
118
136
  }
119
137
  function findRealPnpm() {
138
+ const path = /* @__PURE__ */ getPath();
120
139
  const commonPaths = import_platform.WIN32 ? [
121
140
  // Windows common paths.
122
- import_node_path.default.join((0, import_windows.getAppdata)(), "npm", "pnpm.cmd"),
123
- import_node_path.default.join((0, import_windows.getAppdata)(), "npm", "pnpm"),
124
- import_node_path.default.join((0, import_windows.getLocalappdata)(), "pnpm", "pnpm.cmd"),
125
- import_node_path.default.join((0, import_windows.getLocalappdata)(), "pnpm", "pnpm"),
141
+ path.join((0, import_windows.getAppdata)(), "npm", "pnpm.cmd"),
142
+ path.join((0, import_windows.getAppdata)(), "npm", "pnpm"),
143
+ path.join((0, import_windows.getLocalappdata)(), "pnpm", "pnpm.cmd"),
144
+ path.join((0, import_windows.getLocalappdata)(), "pnpm", "pnpm"),
126
145
  "C:\\Program Files\\nodejs\\pnpm.cmd",
127
146
  "C:\\Program Files\\nodejs\\pnpm"
128
147
  ].filter(Boolean) : [
129
148
  // Unix common paths.
130
149
  "/usr/local/bin/pnpm",
131
150
  "/usr/bin/pnpm",
132
- import_node_path.default.join(
151
+ path.join(
133
152
  (0, import_xdg.getXdgDataHome)() || `${(0, import_home.getHome)()}/.local/share`,
134
153
  "pnpm/pnpm"
135
154
  ),
136
- import_node_path.default.join((0, import_home.getHome)(), ".pnpm/pnpm")
155
+ path.join((0, import_home.getHome)(), ".pnpm/pnpm")
137
156
  ].filter(Boolean);
138
157
  return findRealBin("pnpm", commonPaths) ?? "";
139
158
  }
140
159
  function findRealYarn() {
160
+ const path = /* @__PURE__ */ getPath();
141
161
  const commonPaths = [
142
162
  "/usr/local/bin/yarn",
143
163
  "/usr/bin/yarn",
144
- import_node_path.default.join((0, import_home.getHome)(), ".yarn/bin/yarn"),
145
- import_node_path.default.join(
164
+ path.join((0, import_home.getHome)(), ".yarn/bin/yarn"),
165
+ path.join(
146
166
  (0, import_home.getHome)(),
147
167
  ".config/yarn/global/node_modules/.bin/yarn"
148
168
  )
@@ -158,7 +178,9 @@ function isShadowBinPath(dirPath) {
158
178
  }
159
179
  // @__NO_SIDE_EFFECTS__
160
180
  function resolveRealBinSync(binPath) {
161
- if (!import_node_path.default.isAbsolute(binPath)) {
181
+ const fs = /* @__PURE__ */ getFs();
182
+ const path = /* @__PURE__ */ getPath();
183
+ if (!path.isAbsolute(binPath)) {
162
184
  try {
163
185
  const resolved = whichRealSync(binPath);
164
186
  if (resolved) {
@@ -171,17 +193,17 @@ function resolveRealBinSync(binPath) {
171
193
  if (binPath === ".") {
172
194
  return binPath;
173
195
  }
174
- const ext = import_node_path.default.extname(binPath);
196
+ const ext = path.extname(binPath);
175
197
  const extLowered = ext.toLowerCase();
176
- const basename = import_node_path.default.basename(binPath, ext);
198
+ const basename = path.basename(binPath, ext);
177
199
  const voltaIndex = basename === "node" ? -1 : /(?<=\/)\.volta\//i.exec(binPath)?.index ?? -1;
178
200
  if (voltaIndex !== -1) {
179
201
  const voltaPath = binPath.slice(0, voltaIndex);
180
- const voltaToolsPath = import_node_path.default.join(voltaPath, "tools");
181
- const voltaImagePath = import_node_path.default.join(voltaToolsPath, "image");
182
- const voltaUserPath = import_node_path.default.join(voltaToolsPath, "user");
202
+ const voltaToolsPath = path.join(voltaPath, "tools");
203
+ const voltaImagePath = path.join(voltaToolsPath, "image");
204
+ const voltaUserPath = path.join(voltaToolsPath, "user");
183
205
  const voltaPlatform = (0, import_fs.readJsonSync)(
184
- import_node_path.default.join(voltaUserPath, "platform.json"),
206
+ path.join(voltaUserPath, "platform.json"),
185
207
  { throws: false }
186
208
  );
187
209
  const voltaNodeVersion = voltaPlatform?.node?.runtime;
@@ -190,35 +212,35 @@ function resolveRealBinSync(binPath) {
190
212
  if (basename === "npm" || basename === "npx") {
191
213
  if (voltaNpmVersion) {
192
214
  const relCliPath = `bin/${basename}-cli.js`;
193
- voltaBinPath = import_node_path.default.join(
215
+ voltaBinPath = path.join(
194
216
  voltaImagePath,
195
217
  `npm/${voltaNpmVersion}/${relCliPath}`
196
218
  );
197
- if (voltaNodeVersion && !import_node_fs.default.existsSync(voltaBinPath)) {
198
- voltaBinPath = import_node_path.default.join(
219
+ if (voltaNodeVersion && !fs.existsSync(voltaBinPath)) {
220
+ voltaBinPath = path.join(
199
221
  voltaImagePath,
200
222
  `node/${voltaNodeVersion}/lib/node_modules/npm/${relCliPath}`
201
223
  );
202
- if (!import_node_fs.default.existsSync(voltaBinPath)) {
224
+ if (!fs.existsSync(voltaBinPath)) {
203
225
  voltaBinPath = "";
204
226
  }
205
227
  }
206
228
  }
207
229
  } else {
208
- const voltaUserBinPath = import_node_path.default.join(voltaUserPath, "bin");
230
+ const voltaUserBinPath = path.join(voltaUserPath, "bin");
209
231
  const binInfo = (0, import_fs.readJsonSync)(
210
- import_node_path.default.join(voltaUserBinPath, `${basename}.json`),
232
+ path.join(voltaUserBinPath, `${basename}.json`),
211
233
  { throws: false }
212
234
  );
213
235
  const binPackage = binInfo?.package;
214
236
  if (binPackage) {
215
- voltaBinPath = import_node_path.default.join(
237
+ voltaBinPath = path.join(
216
238
  voltaImagePath,
217
239
  `packages/${binPackage}/bin/${basename}`
218
240
  );
219
- if (!import_node_fs.default.existsSync(voltaBinPath)) {
241
+ if (!fs.existsSync(voltaBinPath)) {
220
242
  voltaBinPath = `${voltaBinPath}.cmd`;
221
- if (!import_node_fs.default.existsSync(voltaBinPath)) {
243
+ if (!fs.existsSync(voltaBinPath)) {
222
244
  voltaBinPath = "";
223
245
  }
224
246
  }
@@ -226,7 +248,7 @@ function resolveRealBinSync(binPath) {
226
248
  }
227
249
  if (voltaBinPath) {
228
250
  try {
229
- return (0, import_normalize.normalizePath)(import_node_fs.default.realpathSync.native(voltaBinPath));
251
+ return (0, import_normalize.normalizePath)(fs.realpathSync.native(voltaBinPath));
230
252
  } catch {
231
253
  }
232
254
  return voltaBinPath;
@@ -237,13 +259,13 @@ function resolveRealBinSync(binPath) {
237
259
  const isNpmOrNpx = basename === "npm" || basename === "npx";
238
260
  const isPnpmOrYarn = basename === "pnpm" || basename === "yarn";
239
261
  if (hasKnownExt && isNpmOrNpx) {
240
- const quickPath = import_node_path.default.join(
241
- import_node_path.default.dirname(binPath),
262
+ const quickPath = path.join(
263
+ path.dirname(binPath),
242
264
  `node_modules/npm/bin/${basename}-cli.js`
243
265
  );
244
- if (import_node_fs.default.existsSync(quickPath)) {
266
+ if (fs.existsSync(quickPath)) {
245
267
  try {
246
- return import_node_fs.default.realpathSync.native(quickPath);
268
+ return fs.realpathSync.native(quickPath);
247
269
  } catch {
248
270
  }
249
271
  return quickPath;
@@ -253,8 +275,8 @@ function resolveRealBinSync(binPath) {
253
275
  if (hasKnownExt && // Only parse shell scripts and batch files, not actual executables.
254
276
  // .exe files are already executables and don't need path resolution from wrapper scripts.
255
277
  extLowered !== ".exe" && // Check if file exists before attempting to read it to avoid ENOENT errors.
256
- import_node_fs.default.existsSync(binPath)) {
257
- const source = import_node_fs.default.readFileSync(binPath, "utf8");
278
+ fs.existsSync(binPath)) {
279
+ const source = fs.readFileSync(binPath, "utf8");
258
280
  if (isNpmOrNpx) {
259
281
  if (extLowered === ".cmd") {
260
282
  relPath = basename === "npm" ? /(?<="NPM_CLI_JS=%~dp0\\).*(?=")/.exec(source)?.[0] || "" : /(?<="NPX_CLI_JS=%~dp0\\).*(?=")/.exec(source)?.[0] || "";
@@ -301,7 +323,7 @@ function resolveRealBinSync(binPath) {
301
323
  relPath = /(?<="\$basedir\/).*(?=" $args\n)/.exec(source)?.[0] || "";
302
324
  }
303
325
  if (relPath) {
304
- binPath = (0, import_normalize.normalizePath)(import_node_path.default.resolve(import_node_path.default.dirname(binPath), relPath));
326
+ binPath = (0, import_normalize.normalizePath)(path.resolve(path.dirname(binPath), relPath));
305
327
  }
306
328
  }
307
329
  } else {
@@ -313,10 +335,10 @@ function resolveRealBinSync(binPath) {
313
335
  if (binIndex !== -1) {
314
336
  const baseBinPath = binPath.slice(0, binIndex + "/.bin/pnpm".length);
315
337
  try {
316
- const stats = import_node_fs.default.statSync(baseBinPath);
338
+ const stats = fs.statSync(baseBinPath);
317
339
  if (stats.isFile()) {
318
340
  binPath = (0, import_normalize.normalizePath)(baseBinPath);
319
- hasNoExt = !import_node_path.default.extname(binPath);
341
+ hasNoExt = !path.extname(binPath);
320
342
  }
321
343
  } catch {
322
344
  }
@@ -324,8 +346,8 @@ function resolveRealBinSync(binPath) {
324
346
  }
325
347
  if (hasNoExt && (isPnpmOrYarn || isNpmOrNpx) && // For extensionless files (Unix shell scripts), verify existence before reading.
326
348
  // This prevents ENOENT errors when the bin path doesn't exist.
327
- import_node_fs.default.existsSync(binPath)) {
328
- const source = import_node_fs.default.readFileSync(binPath, "utf8");
349
+ fs.existsSync(binPath)) {
350
+ const source = fs.readFileSync(binPath, "utf8");
329
351
  let relPath = "";
330
352
  if (isPnpmOrYarn) {
331
353
  relPath = /(?<="\$basedir\/)\.tools\/[^"]+(?="\s+"\$@")/.exec(source)?.[0] || "";
@@ -347,12 +369,12 @@ function resolveRealBinSync(binPath) {
347
369
  relPath = basename === "npm" ? /(?<=NPM_CLI_JS="\$CLI_BASEDIR\/).*(?=")/.exec(source)?.[0] || "" : /(?<=NPX_CLI_JS="\$CLI_BASEDIR\/).*(?=")/.exec(source)?.[0] || "";
348
370
  }
349
371
  if (relPath) {
350
- binPath = (0, import_normalize.normalizePath)(import_node_path.default.resolve(import_node_path.default.dirname(binPath), relPath));
372
+ binPath = (0, import_normalize.normalizePath)(path.resolve(path.dirname(binPath), relPath));
351
373
  }
352
374
  }
353
375
  }
354
376
  try {
355
- const realPath = import_node_fs.default.realpathSync.native(binPath);
377
+ const realPath = fs.realpathSync.native(binPath);
356
378
  return (0, import_normalize.normalizePath)(realPath);
357
379
  } catch {
358
380
  }
@@ -70,8 +70,8 @@ const NPM_BIN_PATH = /* @__PURE__ */ (() => {
70
70
  })();
71
71
  const NPM_REAL_EXEC_PATH = /* @__PURE__ */ (() => {
72
72
  try {
73
- const { existsSync } = require("node:fs");
74
- const path = require("node:path");
73
+ const { existsSync } = require("fs");
74
+ const path = require("path");
75
75
  const npmBin = import_which.default.sync("npm", { nothrow: true });
76
76
  if (!npmBin) {
77
77
  return void 0;
@@ -1,3 +1,24 @@
1
+ /**
2
+ * CPU architecture type.
3
+ */
4
+ export type Arch = NodeJS.Architecture;
5
+ /**
6
+ * Linux libc variant.
7
+ */
8
+ export type Libc = 'glibc' | 'musl';
9
+ /**
10
+ * Operating system platform type.
11
+ */
12
+ export type Platform = NodeJS.Platform;
13
+ /**
14
+ * Get the current CPU architecture (memoized).
15
+ */
16
+ export declare function getArch(): Arch;
17
+ /**
18
+ * Get the current platform (memoized).
19
+ */
20
+ export declare function getPlatform(): Platform;
21
+ // Platform detection (memoized at module load).
1
22
  export declare const DARWIN: boolean;
2
23
  export declare const WIN32: boolean;
3
24
  // File permission modes.
@@ -23,13 +23,35 @@ __export(platform_exports, {
23
23
  S_IXGRP: () => S_IXGRP,
24
24
  S_IXOTH: () => S_IXOTH,
25
25
  S_IXUSR: () => S_IXUSR,
26
- WIN32: () => WIN32
26
+ WIN32: () => WIN32,
27
+ getArch: () => getArch,
28
+ getPlatform: () => getPlatform
27
29
  });
28
30
  module.exports = __toCommonJS(platform_exports);
29
- var import_os = require("os");
30
- const _platform = (0, import_os.platform)();
31
- const DARWIN = _platform === "darwin";
32
- const WIN32 = _platform === "win32";
31
+ let _os;
32
+ // @__NO_SIDE_EFFECTS__
33
+ function getOs() {
34
+ if (_os === void 0) {
35
+ _os = require("os");
36
+ }
37
+ return _os;
38
+ }
39
+ let _arch;
40
+ function getArch() {
41
+ if (_arch === void 0) {
42
+ _arch = (/* @__PURE__ */ getOs()).arch();
43
+ }
44
+ return _arch;
45
+ }
46
+ let _platform;
47
+ function getPlatform() {
48
+ if (_platform === void 0) {
49
+ _platform = (/* @__PURE__ */ getOs()).platform();
50
+ }
51
+ return _platform;
52
+ }
53
+ const DARWIN = getPlatform() === "darwin";
54
+ const WIN32 = getPlatform() === "win32";
33
55
  const S_IXUSR = 64;
34
56
  const S_IXGRP = 8;
35
57
  const S_IXOTH = 1;
@@ -39,5 +61,7 @@ const S_IXOTH = 1;
39
61
  S_IXGRP,
40
62
  S_IXOTH,
41
63
  S_IXUSR,
42
- WIN32
64
+ WIN32,
65
+ getArch,
66
+ getPlatform
43
67
  });
@@ -22,15 +22,22 @@ __export(code_exports, {
22
22
  getCodeCoverage: () => getCodeCoverage
23
23
  });
24
24
  module.exports = __toCommonJS(code_exports);
25
- var import_fs = require("fs");
26
- var import_fs2 = require("../fs");
25
+ var import_fs = require("../fs");
27
26
  var import_objects = require("../objects");
28
27
  var import_spawn = require("../spawn");
28
+ let _fs;
29
29
  let _path;
30
30
  // @__NO_SIDE_EFFECTS__
31
+ function getFs() {
32
+ if (_fs === void 0) {
33
+ _fs = require("fs");
34
+ }
35
+ return _fs;
36
+ }
37
+ // @__NO_SIDE_EFFECTS__
31
38
  function getPath() {
32
39
  if (_path === void 0) {
33
- _path = require("node:path");
40
+ _path = require("path");
34
41
  }
35
42
  return _path;
36
43
  }
@@ -46,7 +53,8 @@ async function getCodeCoverage(options) {
46
53
  if (!coveragePath) {
47
54
  throw new Error("Coverage path is required");
48
55
  }
49
- const coverageExists = await import_fs.promises.access(coveragePath).then(() => true).catch(() => false);
56
+ const fs = /* @__PURE__ */ getFs();
57
+ const coverageExists = await fs.promises.access(coveragePath).then(() => true).catch(() => false);
50
58
  if (!coverageExists) {
51
59
  if (generateIfMissing) {
52
60
  await (0, import_spawn.spawn)("vitest", ["run", "--coverage"], {
@@ -59,7 +67,7 @@ async function getCodeCoverage(options) {
59
67
  );
60
68
  }
61
69
  }
62
- const coverageData = await (0, import_fs2.readJson)(coveragePath);
70
+ const coverageData = await (0, import_fs.readJson)(coveragePath);
63
71
  if (!(0, import_objects.isObjectObject)(coverageData)) {
64
72
  throw new Error(`Invalid coverage data format in "${coveragePath}"`);
65
73
  }
package/dist/debug.js CHANGED
@@ -72,7 +72,7 @@ let _util;
72
72
  // @__NO_SIDE_EFFECTS__
73
73
  function getUtil() {
74
74
  if (_util === void 0) {
75
- _util = require("node:util");
75
+ _util = require("util");
76
76
  }
77
77
  return _util;
78
78
  }
@@ -1,5 +1,5 @@
1
- import type { SpawnExtra, SpawnOptions } from '../spawn';
2
1
  import { spawn } from '../spawn';
2
+ import type { SpawnExtra, SpawnOptions } from '../spawn';
3
3
  export interface DlxBinaryOptions {
4
4
  /**
5
5
  * URL to download the binary from.