node-version-use 2.4.4 → 2.4.5

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.
@@ -1,10 +1,11 @@
1
1
  /**
2
- * Find a system binary by searching PATH, excluding ~/.nvu/bin
2
+ * Find a system binary by searching PATH, excluding ~/.nvu/bin and version directories
3
3
  * Returns the full path to the binary, or null if not found
4
+ * NOTE: Keep in sync with Node.js resolveSystemBinary
4
5
  */
5
6
  export declare function resolveSystemBinary(name: string): string | null;
6
7
  /**
7
- * Get PATH with ~/.nvu/bin removed
8
+ * Get PATH with ~/.nvu/bin and version directories removed
8
9
  * Used to create an environment for spawning system commands
9
10
  */
10
11
  export declare function getPathWithoutNvuBin(): string;
@@ -1,10 +1,11 @@
1
1
  /**
2
- * Find a system binary by searching PATH, excluding ~/.nvu/bin
2
+ * Find a system binary by searching PATH, excluding ~/.nvu/bin and version directories
3
3
  * Returns the full path to the binary, or null if not found
4
+ * NOTE: Keep in sync with Node.js resolveSystemBinary
4
5
  */
5
6
  export declare function resolveSystemBinary(name: string): string | null;
6
7
  /**
7
- * Get PATH with ~/.nvu/bin removed
8
+ * Get PATH with ~/.nvu/bin and version directories removed
8
9
  * Used to create an environment for spawning system commands
9
10
  */
10
11
  export declare function getPathWithoutNvuBin(): string;
@@ -1,7 +1,4 @@
1
- /**
2
- * Resolve system binaries by searching PATH while excluding ~/.nvu/bin
3
- * This mirrors the Go binary's findSystemBinary() function
4
- */ "use strict";
1
+ "use strict";
5
2
  Object.defineProperty(exports, "__esModule", {
6
3
  value: true
7
4
  });
@@ -30,6 +27,7 @@ function _interop_require_default(obj) {
30
27
  }
31
28
  var isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE);
32
29
  var nvuBinDir = _path.default.join((0, _compatts.homedir)(), '.nvu', 'bin');
30
+ var nvuInstalledDir = _path.default.join((0, _compatts.homedir)(), '.nvu', 'installed');
33
31
  var pathKey = (0, _envpathkey.default)(); // PATH or Path or similar
34
32
  var pathDelimiter = _path.default.delimiter ? _path.default.delimiter : isWindows ? ';' : ':';
35
33
  /**
@@ -39,11 +37,12 @@ var pathDelimiter = _path.default.delimiter ? _path.default.delimiter : isWindow
39
37
  return a === b;
40
38
  }
41
39
  /**
42
- * Check if a path is within the nvu bin directory
43
- */ function isInNvuBin(filePath) {
40
+ * Check if a path is within the nvu bin directory or installed versions
41
+ */ function isInNvuDir(filePath) {
44
42
  try {
45
43
  var realPath = _fs.default.realpathSync(filePath);
46
- return realPath.indexOf(_path.default.join('.nvu', 'bin')) >= 0 || pathsEqual(_path.default.dirname(realPath), nvuBinDir);
44
+ // Check for .nvu/bin or .nvu/installed
45
+ return realPath.indexOf(_path.default.join('.nvu', 'bin')) >= 0 || realPath.indexOf(_path.default.join('.nvu', 'installed')) >= 0 || pathsEqual(_path.default.dirname(realPath), nvuBinDir) || pathsEqual(_path.default.dirname(realPath), nvuInstalledDir);
47
46
  } catch (_e) {
48
47
  return false;
49
48
  }
@@ -69,8 +68,8 @@ function resolveSystemBinary(name) {
69
68
  try {
70
69
  var stat = _fs.default.statSync(candidate);
71
70
  if (!stat.isFile()) continue;
72
- // Make sure it's not in ~/.nvu/bin (via symlink)
73
- if (isInNvuBin(candidate)) continue;
71
+ // Make sure it's not in ~/.nvu/bin or ~/.nvu/installed/*/bin
72
+ if (isInNvuDir(candidate)) continue;
74
73
  return candidate;
75
74
  } catch (_e) {
76
75
  // File doesn't exist, continue
@@ -88,6 +87,7 @@ function getPathWithoutNvuBin() {
88
87
  if (!dir) continue;
89
88
  if (pathsEqual(dir, nvuBinDir)) continue;
90
89
  if (dir.indexOf(_path.default.join('.nvu', 'bin')) >= 0) continue;
90
+ if (dir.indexOf(_path.default.join('.nvu', 'installed')) >= 0) continue;
91
91
  filtered.push(dir);
92
92
  }
93
93
  return filtered.join(pathDelimiter);
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/lib/resolveSystemBinary.ts"],"sourcesContent":["/**\n * Resolve system binaries by searching PATH while excluding ~/.nvu/bin\n * This mirrors the Go binary's findSystemBinary() function\n */\nimport envPathKey from 'env-path-key';\nimport fs from 'fs';\nimport path from 'path';\nimport { homedir } from '../compat.ts';\n\nconst isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE);\nconst nvuBinDir = path.join(homedir(), '.nvu', 'bin');\nconst pathKey = envPathKey(); // PATH or Path or similar\nconst pathDelimiter = path.delimiter ? path.delimiter : isWindows ? ';' : ':';\n\n/**\n * Check if two paths are equal (case-insensitive on Windows)\n */\nfunction pathsEqual(a: string, b: string): boolean {\n if (isWindows) return a.toLowerCase() === b.toLowerCase();\n return a === b;\n}\n\n/**\n * Check if a path is within the nvu bin directory\n */\nfunction isInNvuBin(filePath: string): boolean {\n try {\n const realPath = fs.realpathSync(filePath);\n return realPath.indexOf(path.join('.nvu', 'bin')) >= 0 || pathsEqual(path.dirname(realPath), nvuBinDir);\n } catch (_e) {\n return false;\n }\n}\n\n/**\n * Find a system binary by searching PATH, excluding ~/.nvu/bin\n * Returns the full path to the binary, or null if not found\n */\nexport function resolveSystemBinary(name: string): string | null {\n const pathEnv = process.env[pathKey] || '';\n const dirs = pathEnv.split(pathDelimiter);\n\n for (let i = 0; i < dirs.length; i++) {\n const dir = dirs[i];\n if (!dir) continue;\n\n // Skip ~/.nvu/bin\n if (pathsEqual(dir, nvuBinDir)) continue;\n\n // Build candidate path with appropriate extension\n const candidates = isWindows ? [path.join(dir, `${name}.exe`), path.join(dir, `${name}.cmd`), path.join(dir, name)] : [path.join(dir, name)];\n\n for (let j = 0; j < candidates.length; j++) {\n const candidate = candidates[j];\n try {\n const stat = fs.statSync(candidate);\n if (!stat.isFile()) continue;\n\n // Make sure it's not in ~/.nvu/bin (via symlink)\n if (isInNvuBin(candidate)) continue;\n\n return candidate;\n } catch (_e) {\n // File doesn't exist, continue\n }\n }\n }\n\n return null;\n}\n\n/**\n * Get PATH with ~/.nvu/bin removed\n * Used to create an environment for spawning system commands\n */\nexport function getPathWithoutNvuBin(): string {\n const pathEnv = process.env[pathKey] || '';\n const dirs = pathEnv.split(pathDelimiter);\n\n const filtered: string[] = [];\n for (let i = 0; i < dirs.length; i++) {\n const dir = dirs[i];\n if (!dir) continue;\n if (pathsEqual(dir, nvuBinDir)) continue;\n if (dir.indexOf(path.join('.nvu', 'bin')) >= 0) continue;\n filtered.push(dir);\n }\n\n return filtered.join(pathDelimiter);\n}\n"],"names":["getPathWithoutNvuBin","resolveSystemBinary","isWindows","process","platform","test","env","OSTYPE","nvuBinDir","path","join","homedir","pathKey","envPathKey","pathDelimiter","delimiter","pathsEqual","a","b","toLowerCase","isInNvuBin","filePath","realPath","fs","realpathSync","indexOf","dirname","_e","name","pathEnv","dirs","split","i","length","dir","candidates","j","candidate","stat","statSync","isFile","filtered","push"],"mappings":"AAAA;;;CAGC;;;;;;;;;;;QAwEeA;eAAAA;;QArCAC;eAAAA;;;iEAlCO;yDACR;2DACE;wBACO;;;;;;AAExB,IAAMC,YAAYC,QAAQC,QAAQ,KAAK,WAAW,kBAAkBC,IAAI,CAACF,QAAQG,GAAG,CAACC,MAAM;AAC3F,IAAMC,YAAYC,aAAI,CAACC,IAAI,CAACC,IAAAA,iBAAO,KAAI,QAAQ;AAC/C,IAAMC,UAAUC,IAAAA,mBAAU,KAAI,0BAA0B;AACxD,IAAMC,gBAAgBL,aAAI,CAACM,SAAS,GAAGN,aAAI,CAACM,SAAS,GAAGb,YAAY,MAAM;AAE1E;;CAEC,GACD,SAASc,WAAWC,CAAS,EAAEC,CAAS;IACtC,IAAIhB,WAAW,OAAOe,EAAEE,WAAW,OAAOD,EAAEC,WAAW;IACvD,OAAOF,MAAMC;AACf;AAEA;;CAEC,GACD,SAASE,WAAWC,QAAgB;IAClC,IAAI;QACF,IAAMC,WAAWC,WAAE,CAACC,YAAY,CAACH;QACjC,OAAOC,SAASG,OAAO,CAAChB,aAAI,CAACC,IAAI,CAAC,QAA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IAAME,MAAMJ,IAAI,CAACE,EAAE;QACnB,IAAI,CAACE,KAAK;QACV,IAAIlB,WAAWkB,KAAK1B,YAAY;QAChC,IAAI0B,IAAIT,OAAO,CAAChB,aAAI,CAACC,IAAI,CAAC,QAAQ,WAAW,GAAG;QAChD+B,SAASC,IAAI,CAACR;IAChB;IAEA,OAAOO,SAAS/B,IAAI,CAACI;AACvB"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/lib/resolveSystemBinary.ts"],"sourcesContent":["import envPathKey from 'env-path-key';\nimport fs from 'fs';\nimport path from 'path';\nimport { homedir } from '../compat.ts';\n\nconst isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE);\nconst nvuBinDir = path.join(homedir(), '.nvu', 'bin');\nconst nvuInstalledDir = path.join(homedir(), '.nvu', 'installed');\nconst pathKey = envPathKey(); // PATH or Path or similar\nconst pathDelimiter = path.delimiter ? path.delimiter : isWindows ? ';' : ':';\n\n/**\n * Check if two paths are equal (case-insensitive on Windows)\n */\nfunction pathsEqual(a: string, b: string): boolean {\n if (isWindows) return a.toLowerCase() === b.toLowerCase();\n return a === b;\n}\n\n/**\n * Check if a path is within the nvu bin directory or installed versions\n */\nfunction isInNvuDir(filePath: string): boolean {\n try {\n const realPath = fs.realpathSync(filePath);\n // Check for .nvu/bin or .nvu/installed\n return realPath.indexOf(path.join('.nvu', 'bin')) >= 0 || realPath.indexOf(path.join('.nvu', 'installed')) >= 0 || pathsEqual(path.dirname(realPath), nvuBinDir) || pathsEqual(path.dirname(realPath), nvuInstalledDir);\n } catch (_e) {\n return false;\n }\n}\n\n/**\n * Find a system binary by searching PATH, excluding ~/.nvu/bin and version directories\n * Returns the full path to the binary, or null if not found\n * NOTE: Keep in sync with Node.js resolveSystemBinary\n */\nexport function resolveSystemBinary(name: string): string | null {\n const pathEnv = process.env[pathKey] || '';\n const dirs = pathEnv.split(pathDelimiter);\n\n for (let i = 0; i < dirs.length; i++) {\n const dir = dirs[i];\n if (!dir) continue;\n\n // Skip ~/.nvu/bin\n if (pathsEqual(dir, nvuBinDir)) continue;\n\n // Build candidate path with appropriate extension\n const candidates = isWindows ? [path.join(dir, `${name}.exe`), path.join(dir, `${name}.cmd`), path.join(dir, name)] : [path.join(dir, name)];\n\n for (let j = 0; j < candidates.length; j++) {\n const candidate = candidates[j];\n try {\n const stat = fs.statSync(candidate);\n if (!stat.isFile()) continue;\n\n // Make sure it's not in ~/.nvu/bin or ~/.nvu/installed/*/bin\n if (isInNvuDir(candidate)) continue;\n\n return candidate;\n } catch (_e) {\n // File doesn't exist, continue\n }\n }\n }\n\n return null;\n}\n\n/**\n * Get PATH with ~/.nvu/bin and version directories removed\n * Used to create an environment for spawning system commands\n */\nexport function getPathWithoutNvuBin(): string {\n const pathEnv = process.env[pathKey] || '';\n const dirs = pathEnv.split(pathDelimiter);\n\n const filtered: string[] = [];\n for (let i = 0; i < dirs.length; i++) {\n const dir = dirs[i];\n if (!dir) continue;\n if (pathsEqual(dir, nvuBinDir)) continue;\n if (dir.indexOf(path.join('.nvu', 'bin')) >= 0) continue;\n if (dir.indexOf(path.join('.nvu', 'installed')) >= 0) continue;\n filtered.push(dir);\n }\n\n return filtered.join(pathDelimiter);\n}\n"],"names":["getPathWithoutNvuBin","resolveSystemBinary","isWindows","process","platform","test","env","OSTYPE","nvuBinDir","path","join","homedir","nvuInstalledDir","pathKey","envPathKey","pathDelimiter","delimiter","pathsEqual","a","b","toLowerCase","isInNvuDir","filePath","realPath","fs","realpathSync","indexOf","dirname","_e","name","pathEnv","dirs","split","i","length","dir","candidates","j","candidate","stat","statSync","isFile","filtered","push"],"mappings":";;;;;;;;;;;QA0EgBA;eAAAA;;QArCAC;eAAAA;;;iEArCO;yDACR;2DACE;wBACO;;;;;;AAExB,IAAMC,YAAYC,QAAQC,QAAQ,KAAK,WAAW,kBAAkBC,IAAI,CAACF,QAAQG,GAAG,CAACC,MAAM;AAC3F,IAAMC,YAAYC,aAAI,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AAK,AAAC,GAAO,OAALN,MAAK;YAAQpB,aAAI,CAACC,IAAI,CAACyB,KAAKN;SAAM,GAAG;YAACpB,aAAI,CAACC,IAAI,CAACyB,KAAKN;SAAM;QAE5I,IAAK,IAAIQ,IAAI,GAAGA,IAAID,WAAWF,MAAM,EAAEG,IAAK;YAC1C,IAAMC,YAAYF,UAAU,CAACC,EAAE;YAC/B,IAAI;gBACF,IAAME,OAAOf,WAAE,CAACgB,QAAQ,CAACF;gBACzB,IAAI,CAACC,KAAKE,MAAM,IAAI;gBAEpB,6DAA6D;gBAC7D,IAAIpB,WAAWiB,YAAY;gBAE3B,OAAOA;YACT,EAAE,OAAOV,IAAI;YACX,+BAA+B;YACjC;QACF;IACF;IAEA,OAAO;AACT;AAMO,SAAS5B;IACd,IAAM8B,UAAU3B,QAAQG,GAAG,CAACO,QAAQ,IAAI;IACxC,IAAMkB,OAAOD,QAAQE,KAAK,CAACjB;IAE3B,IAAM2B,WAAqB,EAAE;IAC7B,IAAK,IAAIT,IAAI,GAAGA,IAAIF,KAAKG,MAAM,EAAED,IAAK;QACpC,IAAME,MAAMJ,IAAI,CAACE,EAAE;QACnB,IAAI,CAACE,KAAK;QACV,IAAIlB,WAAWkB,KAAK3B,YAAY;QAChC,IAAI2B,IAAIT,OAAO,CAACjB,aAAI,CAACC,IAAI,CAAC,QAAQ,WAAW,GAAG;QAChD,IAAIyB,IAAIT,OAAO,CAACjB,aAAI,CAACC,IAAI,CAAC,QAAQ,iBAAiB,GAAG;QACtDgC,SAASC,IAAI,CAACR;IAChB;IAEA,OAAOO,SAAShC,IAAI,CAACK;AACvB"}
@@ -1,10 +1,11 @@
1
1
  /**
2
- * Find a system binary by searching PATH, excluding ~/.nvu/bin
2
+ * Find a system binary by searching PATH, excluding ~/.nvu/bin and version directories
3
3
  * Returns the full path to the binary, or null if not found
4
+ * NOTE: Keep in sync with Node.js resolveSystemBinary
4
5
  */
5
6
  export declare function resolveSystemBinary(name: string): string | null;
6
7
  /**
7
- * Get PATH with ~/.nvu/bin removed
8
+ * Get PATH with ~/.nvu/bin and version directories removed
8
9
  * Used to create an environment for spawning system commands
9
10
  */
10
11
  export declare function getPathWithoutNvuBin(): string;
@@ -1,12 +1,10 @@
1
- /**
2
- * Resolve system binaries by searching PATH while excluding ~/.nvu/bin
3
- * This mirrors the Go binary's findSystemBinary() function
4
- */ import envPathKey from 'env-path-key';
1
+ import envPathKey from 'env-path-key';
5
2
  import fs from 'fs';
6
3
  import path from 'path';
7
4
  import { homedir } from '../compat.js';
8
5
  const isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE);
9
6
  const nvuBinDir = path.join(homedir(), '.nvu', 'bin');
7
+ const nvuInstalledDir = path.join(homedir(), '.nvu', 'installed');
10
8
  const pathKey = envPathKey(); // PATH or Path or similar
11
9
  const pathDelimiter = path.delimiter ? path.delimiter : isWindows ? ';' : ':';
12
10
  /**
@@ -16,18 +14,20 @@ const pathDelimiter = path.delimiter ? path.delimiter : isWindows ? ';' : ':';
16
14
  return a === b;
17
15
  }
18
16
  /**
19
- * Check if a path is within the nvu bin directory
20
- */ function isInNvuBin(filePath) {
17
+ * Check if a path is within the nvu bin directory or installed versions
18
+ */ function isInNvuDir(filePath) {
21
19
  try {
22
20
  const realPath = fs.realpathSync(filePath);
23
- return realPath.indexOf(path.join('.nvu', 'bin')) >= 0 || pathsEqual(path.dirname(realPath), nvuBinDir);
21
+ // Check for .nvu/bin or .nvu/installed
22
+ return realPath.indexOf(path.join('.nvu', 'bin')) >= 0 || realPath.indexOf(path.join('.nvu', 'installed')) >= 0 || pathsEqual(path.dirname(realPath), nvuBinDir) || pathsEqual(path.dirname(realPath), nvuInstalledDir);
24
23
  } catch (_e) {
25
24
  return false;
26
25
  }
27
26
  }
28
27
  /**
29
- * Find a system binary by searching PATH, excluding ~/.nvu/bin
28
+ * Find a system binary by searching PATH, excluding ~/.nvu/bin and version directories
30
29
  * Returns the full path to the binary, or null if not found
30
+ * NOTE: Keep in sync with Node.js resolveSystemBinary
31
31
  */ export function resolveSystemBinary(name) {
32
32
  const pathEnv = process.env[pathKey] || '';
33
33
  const dirs = pathEnv.split(pathDelimiter);
@@ -49,8 +49,8 @@ const pathDelimiter = path.delimiter ? path.delimiter : isWindows ? ';' : ':';
49
49
  try {
50
50
  const stat = fs.statSync(candidate);
51
51
  if (!stat.isFile()) continue;
52
- // Make sure it's not in ~/.nvu/bin (via symlink)
53
- if (isInNvuBin(candidate)) continue;
52
+ // Make sure it's not in ~/.nvu/bin or ~/.nvu/installed/*/bin
53
+ if (isInNvuDir(candidate)) continue;
54
54
  return candidate;
55
55
  } catch (_e) {
56
56
  // File doesn't exist, continue
@@ -60,7 +60,7 @@ const pathDelimiter = path.delimiter ? path.delimiter : isWindows ? ';' : ':';
60
60
  return null;
61
61
  }
62
62
  /**
63
- * Get PATH with ~/.nvu/bin removed
63
+ * Get PATH with ~/.nvu/bin and version directories removed
64
64
  * Used to create an environment for spawning system commands
65
65
  */ export function getPathWithoutNvuBin() {
66
66
  const pathEnv = process.env[pathKey] || '';
@@ -71,6 +71,7 @@ const pathDelimiter = path.delimiter ? path.delimiter : isWindows ? ';' : ':';
71
71
  if (!dir) continue;
72
72
  if (pathsEqual(dir, nvuBinDir)) continue;
73
73
  if (dir.indexOf(path.join('.nvu', 'bin')) >= 0) continue;
74
+ if (dir.indexOf(path.join('.nvu', 'installed')) >= 0) continue;
74
75
  filtered.push(dir);
75
76
  }
76
77
  return filtered.join(pathDelimiter);
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/lib/resolveSystemBinary.ts"],"sourcesContent":["/**\n * Resolve system binaries by searching PATH while excluding ~/.nvu/bin\n * This mirrors the Go binary's findSystemBinary() function\n */\nimport envPathKey from 'env-path-key';\nimport fs from 'fs';\nimport path from 'path';\nimport { homedir } from '../compat.ts';\n\nconst isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE);\nconst nvuBinDir = path.join(homedir(), '.nvu', 'bin');\nconst pathKey = envPathKey(); // PATH or Path or similar\nconst pathDelimiter = path.delimiter ? path.delimiter : isWindows ? ';' : ':';\n\n/**\n * Check if two paths are equal (case-insensitive on Windows)\n */\nfunction pathsEqual(a: string, b: string): boolean {\n if (isWindows) return a.toLowerCase() === b.toLowerCase();\n return a === b;\n}\n\n/**\n * Check if a path is within the nvu bin directory\n */\nfunction isInNvuBin(filePath: string): boolean {\n try {\n const realPath = fs.realpathSync(filePath);\n return realPath.indexOf(path.join('.nvu', 'bin')) >= 0 || pathsEqual(path.dirname(realPath), nvuBinDir);\n } catch (_e) {\n return false;\n }\n}\n\n/**\n * Find a system binary by searching PATH, excluding ~/.nvu/bin\n * Returns the full path to the binary, or null if not found\n */\nexport function resolveSystemBinary(name: string): string | null {\n const pathEnv = process.env[pathKey] || '';\n const dirs = pathEnv.split(pathDelimiter);\n\n for (let i = 0; i < dirs.length; i++) {\n const dir = dirs[i];\n if (!dir) continue;\n\n // Skip ~/.nvu/bin\n if (pathsEqual(dir, nvuBinDir)) continue;\n\n // Build candidate path with appropriate extension\n const candidates = isWindows ? [path.join(dir, `${name}.exe`), path.join(dir, `${name}.cmd`), path.join(dir, name)] : [path.join(dir, name)];\n\n for (let j = 0; j < candidates.length; j++) {\n const candidate = candidates[j];\n try {\n const stat = fs.statSync(candidate);\n if (!stat.isFile()) continue;\n\n // Make sure it's not in ~/.nvu/bin (via symlink)\n if (isInNvuBin(candidate)) continue;\n\n return candidate;\n } catch (_e) {\n // File doesn't exist, continue\n }\n }\n }\n\n return null;\n}\n\n/**\n * Get PATH with ~/.nvu/bin removed\n * Used to create an environment for spawning system commands\n */\nexport function getPathWithoutNvuBin(): string {\n const pathEnv = process.env[pathKey] || '';\n const dirs = pathEnv.split(pathDelimiter);\n\n const filtered: string[] = [];\n for (let i = 0; i < dirs.length; i++) {\n const dir = dirs[i];\n if (!dir) continue;\n if (pathsEqual(dir, nvuBinDir)) continue;\n if (dir.indexOf(path.join('.nvu', 'bin')) >= 0) continue;\n filtered.push(dir);\n }\n\n return filtered.join(pathDelimiter);\n}\n"],"names":["envPathKey","fs","path","homedir","isWindows","process","platform","test","env","OSTYPE","nvuBinDir","join","pathKey","pathDelimiter","delimiter","pathsEqual","a","b","toLowerCase","isInNvuBin","filePath","realPath","realpathSync","indexOf","dirname","_e","resolveSystemBinary","name","pathEnv","dirs","split","i","length","dir","candidates","j","candidate","stat","statSync","isFile","getPathWithoutNvuBin","filtered","push"],"mappings":"AAAA;;;CAGC,GACD,OAAOA,gBAAgB,eAAe;AACtC,OAAOC,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AACxB,SAASC,OAAO,QAAQ,eAAe;AAEvC,MAAMC,YAAYC,QAAQC,QAAQ,KAAK,WAAW,kBAAkBC,IAAI,CAACF,QAAQG,GAAG,CAACC,MAAM;AAC3F,MAAMC,YAAYR,KAAKS,IAAI,CAACR,WAAW,QAAQ;AAC/C,MAAMS,UAAUZ,cAAc,0BAA0B;AACxD,MAAMa,gBAAgBX,KAAKY,SAAS,GAAGZ,KAAKY,SAAS,GAAGV,YAAY,MAAM;AAE1E;;CAEC,GACD,SAASW,WAAWC,CAAS,EAAEC,CAAS;IACtC,IAAIb,WAAW,OAAOY,EAAEE,WAAW,OAAOD,EAAEC,WAAW;IACvD,OAAOF,MAAMC;AACf;AAEA;;CAEC,GACD,SAASE,WAAWC,QAAgB;IAClC,IAAI;QACF,MAAMC,WAAWpB,GAAGqB,YAAY,CAACF;QACjC,OAAOC,SAASE,OAAO,CAACrB,KAAKS,IAAI,CAAC,QAAQ,WAAW,KAAKI,WAAWb,KAAKsB,OAAO,CAACH,WAAWX;IAC/F,EAAE,OAAOe,IAAI;QACX,OAAO;IACT;AACF;AAEA;;;CAGC,GACD,OAAO,SAASC,oBAAoBC,IAAY;IAC9C,MAAMC,UAAUvB,QAAQG,GAAG,CAACI,QAAQ,IAAI;IACxC,MAAMiB,OAAOD,QAAQE,KAAK,CAACjB;IA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}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/lib/resolveSystemBinary.ts"],"sourcesContent":["import envPathKey from 'env-path-key';\nimport fs from 'fs';\nimport path from 'path';\nimport { homedir } from '../compat.ts';\n\nconst isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE);\nconst nvuBinDir = path.join(homedir(), '.nvu', 'bin');\nconst nvuInstalledDir = path.join(homedir(), '.nvu', 'installed');\nconst pathKey = envPathKey(); // PATH or Path or similar\nconst pathDelimiter = path.delimiter ? path.delimiter : isWindows ? ';' : ':';\n\n/**\n * Check if two paths are equal (case-insensitive on Windows)\n */\nfunction pathsEqual(a: string, b: string): boolean {\n if (isWindows) return a.toLowerCase() === b.toLowerCase();\n return a === b;\n}\n\n/**\n * Check if a path is within the nvu bin directory or installed versions\n */\nfunction isInNvuDir(filePath: string): boolean {\n try {\n const realPath = fs.realpathSync(filePath);\n // Check for .nvu/bin or .nvu/installed\n return realPath.indexOf(path.join('.nvu', 'bin')) >= 0 || realPath.indexOf(path.join('.nvu', 'installed')) >= 0 || pathsEqual(path.dirname(realPath), nvuBinDir) || pathsEqual(path.dirname(realPath), nvuInstalledDir);\n } catch (_e) {\n return false;\n }\n}\n\n/**\n * Find a system binary by searching PATH, excluding ~/.nvu/bin and version directories\n * Returns the full path to the binary, or null if not found\n * NOTE: Keep in sync with Node.js resolveSystemBinary\n */\nexport function resolveSystemBinary(name: string): string | null {\n const pathEnv = process.env[pathKey] || '';\n const dirs = pathEnv.split(pathDelimiter);\n\n for (let i = 0; i < dirs.length; i++) {\n const dir = dirs[i];\n if (!dir) continue;\n\n // Skip ~/.nvu/bin\n if (pathsEqual(dir, nvuBinDir)) continue;\n\n // Build candidate path with appropriate extension\n const candidates = isWindows ? [path.join(dir, `${name}.exe`), path.join(dir, `${name}.cmd`), path.join(dir, name)] : [path.join(dir, name)];\n\n for (let j = 0; j < candidates.length; j++) {\n const candidate = candidates[j];\n try {\n const stat = fs.statSync(candidate);\n if (!stat.isFile()) continue;\n\n // Make sure it's not in ~/.nvu/bin or ~/.nvu/installed/*/bin\n if (isInNvuDir(candidate)) continue;\n\n return candidate;\n } catch (_e) {\n // File doesn't exist, continue\n }\n }\n }\n\n return null;\n}\n\n/**\n * Get PATH with ~/.nvu/bin and version directories removed\n * Used to create an environment for spawning system commands\n */\nexport function getPathWithoutNvuBin(): string {\n const pathEnv = process.env[pathKey] || '';\n const dirs = pathEnv.split(pathDelimiter);\n\n const filtered: string[] = [];\n for (let i = 0; i < dirs.length; i++) {\n const dir = dirs[i];\n if (!dir) continue;\n if (pathsEqual(dir, nvuBinDir)) continue;\n if (dir.indexOf(path.join('.nvu', 'bin')) >= 0) continue;\n if (dir.indexOf(path.join('.nvu', 'installed')) >= 0) continue;\n filtered.push(dir);\n }\n\n return filtered.join(pathDelimiter);\n}\n"],"names":["envPathKey","fs","path","homedir","isWindows","process","platform","test","env","OSTYPE","nvuBinDir","join","nvuInstalledDir","pathKey","pathDelimiter","delimiter","pathsEqual","a","b","toLowerCase","isInNvuDir","filePath","realPath","realpathSync","indexOf","dirname","_e","resolveSystemBinary","name","pathEnv","dirs","split","i","length","dir","candidates","j","candidate","stat","statSync","isFile","getPathWithoutNvuBin","filtered","push"],"mappings":"AAAA,OAAOA,gBAAgB,eAAe;AACtC,OAAOC,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AACxB,SAASC,OAAO,QAAQ,eAAe;AAEvC,MAAMC,YAAYC,QAAQC,QAAQ,KAAK,WAAW,kBAAkBC,IAAI,CAACF,QAAQG,GAAG,CAACC,MAAM;AAC3F,MAAMC,YAAYR,KAAKS,IAAI,CAACR,WAAW,QAAQ;AAC/C,MAAMS,kBAAkBV,KAAKS,IAAI,CAACR,WAAW,QAAQ;AACrD,MAAMU,UAAUb,cAAc,0BAA0B;AACxD,MAAMc,gBAAgBZ,KAAKa,SAAS,GAAGb,KAAKa,SAAS,GAAGX,YAAY,MAAM;AAE1E;;CAEC,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B,IAAI,CAACC,KAAKE,MAAM,IAAI;gBAEpB,6DAA6D;gBAC7D,IAAIpB,WAAWiB,YAAY;gBAE3B,OAAOA;YACT,EAAE,OAAOX,IAAI;YACX,+BAA+B;YACjC;QACF;IACF;IAEA,OAAO;AACT;AAEA;;;CAGC,GACD,OAAO,SAASe;IACd,MAAMZ,UAAUxB,QAAQG,GAAG,CAACK,QAAQ,IAAI;IACxC,MAAMiB,OAAOD,QAAQE,KAAK,CAACjB;IAE3B,MAAM4B,WAAqB,EAAE;IAC7B,IAAK,IAAIV,IAAI,GAAGA,IAAIF,KAAKG,MAAM,EAAED,IAAK;QACpC,MAAME,MAAMJ,IAAI,CAACE,EAAE;QACnB,IAAI,CAACE,KAAK;QACV,IAAIlB,WAAWkB,KAAKxB,YAAY;QAChC,IAAIwB,IAAIV,OAAO,CAACtB,KAAKS,IAAI,CAAC,QAAQ,WAAW,GAAG;QAChD,IAAIuB,IAAIV,OAAO,CAACtB,KAAKS,IAAI,CAAC,QAAQ,iBAAiB,GAAG;QACtD+B,SAASC,IAAI,CAACT;IAChB;IAEA,OAAOQ,SAAS/B,IAAI,CAACG;AACvB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-version-use",
3
- "version": "2.4.4",
3
+ "version": "2.4.5",
4
4
  "description": "Cross-platform solution for using multiple versions of node. Useful for compatibility testing",
5
5
  "keywords": [
6
6
  "node",