node-version-use 2.4.1 → 2.4.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/cjs/commands/which.js +15 -0
- package/dist/cjs/commands/which.js.map +1 -1
- package/dist/cjs/compat.d.cts +1 -0
- package/dist/cjs/compat.d.ts +1 -0
- package/dist/cjs/compat.js +17 -3
- package/dist/cjs/compat.js.map +1 -1
- package/dist/cjs/lib/loadNodeVersionInstall.js +1 -1
- package/dist/cjs/lib/loadNodeVersionInstall.js.map +1 -1
- package/dist/cjs/lib/resolveSystemBinary.d.cts +10 -0
- package/dist/cjs/lib/resolveSystemBinary.d.ts +10 -0
- package/dist/cjs/lib/resolveSystemBinary.js +96 -0
- package/dist/cjs/lib/resolveSystemBinary.js.map +1 -0
- package/dist/cjs/worker.js +53 -56
- package/dist/cjs/worker.js.map +1 -1
- package/dist/esm/commands/which.js +15 -0
- package/dist/esm/commands/which.js.map +1 -1
- package/dist/esm/compat.d.ts +1 -0
- package/dist/esm/compat.js +16 -5
- package/dist/esm/compat.js.map +1 -1
- package/dist/esm/lib/loadNodeVersionInstall.js +1 -1
- package/dist/esm/lib/loadNodeVersionInstall.js.map +1 -1
- package/dist/esm/lib/resolveSystemBinary.d.ts +10 -0
- package/dist/esm/lib/resolveSystemBinary.js +78 -0
- package/dist/esm/lib/resolveSystemBinary.js.map +1 -0
- package/dist/esm/worker.js +58 -11
- package/dist/esm/worker.js.map +1 -1
- package/package.json +2 -2
|
@@ -18,6 +18,7 @@ var _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
|
18
18
|
var _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
19
19
|
var _constantsts = require("../constants.js");
|
|
20
20
|
var _findInstalledVersionsts = require("../lib/findInstalledVersions.js");
|
|
21
|
+
var _resolveSystemBinaryts = require("../lib/resolveSystemBinary.js");
|
|
21
22
|
function _interop_require_default(obj) {
|
|
22
23
|
return obj && obj.__esModule ? obj : {
|
|
23
24
|
default: obj
|
|
@@ -36,6 +37,20 @@ function whichCmd(_args) {
|
|
|
36
37
|
(0, _exitcompat.default)(1);
|
|
37
38
|
return;
|
|
38
39
|
}
|
|
40
|
+
// Handle "system" version specially
|
|
41
|
+
if (version === 'system') {
|
|
42
|
+
console.log('Version: system');
|
|
43
|
+
console.log("Source: ".concat(getVersionSource(cwd)));
|
|
44
|
+
var systemNode = (0, _resolveSystemBinaryts.resolveSystemBinary)('node');
|
|
45
|
+
console.log("Binary: ".concat(systemNode || 'not found'));
|
|
46
|
+
if (systemNode) {
|
|
47
|
+
console.log('Status: Available');
|
|
48
|
+
} else {
|
|
49
|
+
console.log('Status: Not found (install Node.js on your system)');
|
|
50
|
+
}
|
|
51
|
+
(0, _exitcompat.default)(0);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
39
54
|
// Resolve partial version to exact installed version
|
|
40
55
|
var versionsPath = _path.default.join(_constantsts.storagePath, 'installed');
|
|
41
56
|
var matches = (0, _findInstalledVersionsts.findInstalledVersions)(versionsPath, version);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/which.ts"],"sourcesContent":["import exit from 'exit-compat';\nimport fs from 'fs';\nimport path from 'path';\nimport { storagePath } from '../constants.ts';\nimport { findInstalledVersions } from '../lib/findInstalledVersions.ts';\n\n/**\n * nvu which\n *\n * Show which Node binary would be used based on current directory.\n * This simulates what the nvu binary would do.\n */\nexport default function whichCmd(_args: string[]): void {\n const cwd = process.cwd();\n\n // Resolve version using the same logic as the nvu binary\n const version = resolveVersion(cwd);\n\n if (!version) {\n console.log('No Node version configured for this directory.');\n console.log('');\n console.log('To configure a version:');\n console.log(' nvu local <version> - Set version for this project');\n console.log(' nvu default <version> - Set global default');\n exit(1);\n return;\n }\n\n // Resolve partial version to exact installed version\n const versionsPath = path.join(storagePath, 'installed');\n const matches = findInstalledVersions(versionsPath, version);\n const resolvedVersion = matches.length > 0 ? matches[matches.length - 1] : null;\n\n // Display version (show resolution if different)\n if (resolvedVersion && resolvedVersion !== version && resolvedVersion !== `v${version}`) {\n console.log(`Version: ${version} \\u2192 ${resolvedVersion}`);\n } else {\n console.log(`Version: ${resolvedVersion || version}`);\n }\n console.log(`Source: ${getVersionSource(cwd)}`);\n\n if (resolvedVersion) {\n const actualVersionPath = path.join(versionsPath, resolvedVersion);\n const nodePath = path.join(actualVersionPath, 'bin', 'node');\n console.log(`Binary: ${nodePath}`);\n if (fs.existsSync(nodePath)) {\n console.log('Status: Installed');\n } else {\n console.log('Status: Directory exists but binary not found');\n }\n } else {\n console.log(`Status: Not installed (run: nvu install ${version})`);\n }\n\n exit(0);\n}\n\n/**\n * Resolve version from config files (mirrors nvu binary logic)\n */\nfunction resolveVersion(cwd: string): string | null {\n // Walk up directories looking for .nvurc or .nvmrc\n let dir = cwd;\n while (true) {\n // Check .nvurc first\n const nvurcPath = path.join(dir, '.nvurc');\n if (fs.existsSync(nvurcPath)) {\n return fs.readFileSync(nvurcPath, 'utf8').trim();\n }\n\n // Check .nvmrc\n const nvmrcPath = path.join(dir, '.nvmrc');\n if (fs.existsSync(nvmrcPath)) {\n return fs.readFileSync(nvmrcPath, 'utf8').trim();\n }\n\n // Move to parent\n const parent = path.dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n\n // Check global default\n const defaultPath = path.join(storagePath, 'default');\n if (fs.existsSync(defaultPath)) {\n return fs.readFileSync(defaultPath, 'utf8').trim();\n }\n\n return null;\n}\n\n/**\n * Determine the source of the version (for display)\n */\nfunction getVersionSource(cwd: string): string {\n let dir = cwd;\n while (true) {\n const nvurcPath = path.join(dir, '.nvurc');\n if (fs.existsSync(nvurcPath)) {\n return nvurcPath;\n }\n\n const nvmrcPath = path.join(dir, '.nvmrc');\n if (fs.existsSync(nvmrcPath)) {\n return nvmrcPath;\n }\n\n const parent = path.dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n\n const defaultPath = path.join(storagePath, 'default');\n if (fs.existsSync(defaultPath)) {\n return `${defaultPath} (global default)`;\n }\n\n return 'none';\n}\n"],"names":["whichCmd","_args","cwd","process","version","resolveVersion","console","log","exit","versionsPath","path","join","storagePath","matches","findInstalledVersions","resolvedVersion","length","
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/which.ts"],"sourcesContent":["import exit from 'exit-compat';\nimport fs from 'fs';\nimport path from 'path';\nimport { storagePath } from '../constants.ts';\nimport { findInstalledVersions } from '../lib/findInstalledVersions.ts';\nimport { resolveSystemBinary } from '../lib/resolveSystemBinary.ts';\n\n/**\n * nvu which\n *\n * Show which Node binary would be used based on current directory.\n * This simulates what the nvu binary would do.\n */\nexport default function whichCmd(_args: string[]): void {\n const cwd = process.cwd();\n\n // Resolve version using the same logic as the nvu binary\n const version = resolveVersion(cwd);\n\n if (!version) {\n console.log('No Node version configured for this directory.');\n console.log('');\n console.log('To configure a version:');\n console.log(' nvu local <version> - Set version for this project');\n console.log(' nvu default <version> - Set global default');\n exit(1);\n return;\n }\n\n // Handle \"system\" version specially\n if (version === 'system') {\n console.log('Version: system');\n console.log(`Source: ${getVersionSource(cwd)}`);\n const systemNode = resolveSystemBinary('node');\n console.log(`Binary: ${systemNode || 'not found'}`);\n if (systemNode) {\n console.log('Status: Available');\n } else {\n console.log('Status: Not found (install Node.js on your system)');\n }\n exit(0);\n return;\n }\n\n // Resolve partial version to exact installed version\n const versionsPath = path.join(storagePath, 'installed');\n const matches = findInstalledVersions(versionsPath, version);\n const resolvedVersion = matches.length > 0 ? matches[matches.length - 1] : null;\n\n // Display version (show resolution if different)\n if (resolvedVersion && resolvedVersion !== version && resolvedVersion !== `v${version}`) {\n console.log(`Version: ${version} \\u2192 ${resolvedVersion}`);\n } else {\n console.log(`Version: ${resolvedVersion || version}`);\n }\n console.log(`Source: ${getVersionSource(cwd)}`);\n\n if (resolvedVersion) {\n const actualVersionPath = path.join(versionsPath, resolvedVersion);\n const nodePath = path.join(actualVersionPath, 'bin', 'node');\n console.log(`Binary: ${nodePath}`);\n if (fs.existsSync(nodePath)) {\n console.log('Status: Installed');\n } else {\n console.log('Status: Directory exists but binary not found');\n }\n } else {\n console.log(`Status: Not installed (run: nvu install ${version})`);\n }\n\n exit(0);\n}\n\n/**\n * Resolve version from config files (mirrors nvu binary logic)\n */\nfunction resolveVersion(cwd: string): string | null {\n // Walk up directories looking for .nvurc or .nvmrc\n let dir = cwd;\n while (true) {\n // Check .nvurc first\n const nvurcPath = path.join(dir, '.nvurc');\n if (fs.existsSync(nvurcPath)) {\n return fs.readFileSync(nvurcPath, 'utf8').trim();\n }\n\n // Check .nvmrc\n const nvmrcPath = path.join(dir, '.nvmrc');\n if (fs.existsSync(nvmrcPath)) {\n return fs.readFileSync(nvmrcPath, 'utf8').trim();\n }\n\n // Move to parent\n const parent = path.dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n\n // Check global default\n const defaultPath = path.join(storagePath, 'default');\n if (fs.existsSync(defaultPath)) {\n return fs.readFileSync(defaultPath, 'utf8').trim();\n }\n\n return null;\n}\n\n/**\n * Determine the source of the version (for display)\n */\nfunction getVersionSource(cwd: string): string {\n let dir = cwd;\n while (true) {\n const nvurcPath = path.join(dir, '.nvurc');\n if (fs.existsSync(nvurcPath)) {\n return nvurcPath;\n }\n\n const nvmrcPath = path.join(dir, '.nvmrc');\n if (fs.existsSync(nvmrcPath)) {\n return nvmrcPath;\n }\n\n const parent = path.dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n\n const defaultPath = path.join(storagePath, 'default');\n if (fs.existsSync(defaultPath)) {\n return `${defaultPath} (global default)`;\n }\n\n return 'none';\n}\n"],"names":["whichCmd","_args","cwd","process","version","resolveVersion","console","log","exit","getVersionSource","systemNode","resolveSystemBinary","versionsPath","path","join","storagePath","matches","findInstalledVersions","resolvedVersion","length","actualVersionPath","nodePath","fs","existsSync","dir","nvurcPath","readFileSync","trim","nvmrcPath","parent","dirname","defaultPath"],"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,aAAI,CAACC,IAAI,CAACU,KAAK;QACjC,IAAIF,WAAE,CAACC,UAAU,CAACE,YAAY;YAC5B,OAAOA;QACT;QAEA,IAAMG,YAAYf,aAAI,CAACC,IAAI,CAACU,KAAK;QACjC,IAAIF,WAAE,CAACC,UAAU,CAACK,YAAY;YAC5B,OAAOA;QACT;QAEA,IAAMC,SAAShB,aAAI,CAACiB,OAAO,CAACN;QAC5B,IAAIK,WAAWL,KAAK;QACpBA,MAAMK;IACR;IAEA,IAAME,cAAclB,aAAI,CAACC,IAAI,CAACC,wBAAW,EAAE;IAC3C,IAAIO,WAAE,CAACC,UAAU,CAACQ,cAAc;QAC9B,OAAO,AAAC,GAAc,OAAZA,aAAY;IACxB;IAEA,OAAO;AACT"}
|
package/dist/cjs/compat.d.cts
CHANGED
package/dist/cjs/compat.d.ts
CHANGED
package/dist/cjs/compat.js
CHANGED
|
@@ -18,6 +18,9 @@ _export(exports, {
|
|
|
18
18
|
get mkdirpSync () {
|
|
19
19
|
return mkdirpSync;
|
|
20
20
|
},
|
|
21
|
+
get objectAssign () {
|
|
22
|
+
return objectAssign;
|
|
23
|
+
},
|
|
21
24
|
get readdirWithTypes () {
|
|
22
25
|
return readdirWithTypes;
|
|
23
26
|
},
|
|
@@ -54,9 +57,7 @@ function tmpdir() {
|
|
|
54
57
|
* - Falls back to lastIndexOf on Node 0.8-3.x
|
|
55
58
|
*/ var hasEndsWith = typeof String.prototype.endsWith === 'function';
|
|
56
59
|
function stringEndsWith(str, search, position) {
|
|
57
|
-
if (hasEndsWith)
|
|
58
|
-
return str.endsWith(search, position);
|
|
59
|
-
}
|
|
60
|
+
if (hasEndsWith) return str.endsWith(search, position);
|
|
60
61
|
var len = position === undefined ? str.length : position;
|
|
61
62
|
return str.lastIndexOf(search) === len - search.length;
|
|
62
63
|
}
|
|
@@ -92,4 +93,17 @@ function readdirWithTypes(dir) {
|
|
|
92
93
|
};
|
|
93
94
|
});
|
|
94
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Object.assign wrapper for Node.js 0.8+
|
|
98
|
+
* - Uses native Object.assign on Node 4.0+
|
|
99
|
+
* - Falls back to manual property copy on Node 0.8-3.x
|
|
100
|
+
*/ var hasObjectAssign = typeof Object.assign === 'function';
|
|
101
|
+
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
102
|
+
function objectAssign(target, source) {
|
|
103
|
+
if (hasObjectAssign) return Object.assign(target, source);
|
|
104
|
+
for(var key in source){
|
|
105
|
+
if (_hasOwnProperty.call(source, key)) target[key] = source[key];
|
|
106
|
+
}
|
|
107
|
+
return target;
|
|
108
|
+
}
|
|
95
109
|
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
package/dist/cjs/compat.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/compat.ts"],"sourcesContent":["/**\n * Compatibility Layer for Node.js 0.8+\n * Local to this package - contains only needed functions.\n */\nimport fs from 'fs';\nimport
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/compat.ts"],"sourcesContent":["/**\n * Compatibility Layer for Node.js 0.8+\n * Local to this package - contains only needed functions.\n */\nimport fs from 'fs';\nimport Module from 'module';\nimport os from 'os';\nimport path from 'path';\n\n// Use existing require in CJS, or createRequire in ESM (Node 12.2+)\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\nexport function homedir(): string {\n return typeof os.homedir === 'function' ? os.homedir() : require('homedir-polyfill')();\n}\n\nexport function tmpdir(): string {\n return typeof os.tmpdir === 'function' ? os.tmpdir() : require('os-shim').tmpdir();\n}\n\n/**\n * String.prototype.endsWith wrapper for Node.js 0.8+\n * - Uses native endsWith on Node 4.0+ / ES2015+\n * - Falls back to lastIndexOf on Node 0.8-3.x\n */\nconst hasEndsWith = typeof String.prototype.endsWith === 'function';\nexport function stringEndsWith(str: string, search: string, position?: number): boolean {\n if (hasEndsWith) return str.endsWith(search, position);\n const len = position === undefined ? str.length : position;\n return str.lastIndexOf(search) === len - search.length;\n}\n\n/**\n * Recursive mkdir for Node.js 0.8+\n */\nexport function mkdirpSync(dir: string): void {\n const mkdirp = _require('mkdirp-classic');\n mkdirp.sync(dir);\n}\n\n/**\n * Recursive rm for Node.js 0.8+\n */\nexport function rmSync(dir: string): void {\n const safeRmSync = _require('fs-remove-compat').safeRmSync;\n safeRmSync(dir);\n}\n\n/**\n * Read directory entries with types for Node.js 0.8+\n * Returns array of {name, isDirectory()}\n */\nexport interface DirEntry {\n name: string;\n isDirectory(): boolean;\n}\n\nexport function readdirWithTypes(dir: string): DirEntry[] {\n const names = fs.readdirSync(dir);\n return names.map((name) => {\n const fullPath = path.join(dir, name);\n let stat: fs.Stats;\n try {\n stat = fs.statSync(fullPath);\n } catch (_e) {\n // If stat fails, treat as non-directory\n return { name: name, isDirectory: () => false };\n }\n return {\n name: name,\n isDirectory: () => stat.isDirectory(),\n };\n });\n}\n\n/**\n * Object.assign wrapper for Node.js 0.8+\n * - Uses native Object.assign on Node 4.0+\n * - Falls back to manual property copy on Node 0.8-3.x\n */\nconst hasObjectAssign = typeof Object.assign === 'function';\nconst _hasOwnProperty = Object.prototype.hasOwnProperty;\n\nexport function objectAssign<T, U>(target: T, source: U): T & U {\n if (hasObjectAssign) return Object.assign(target, source);\n\n for (const key in source) {\n if (_hasOwnProperty.call(source, key)) (target as Record<string, unknown>)[key] = source[key];\n }\n return target as T & U;\n}\n"],"names":["homedir","mkdirpSync","objectAssign","readdirWithTypes","rmSync","stringEndsWith","tmpdir","_require","require","Module","createRequire","os","hasEndsWith","String","prototype","endsWith","str","search","position","len","undefined","length","lastIndexOf","dir","mkdirp","sync","safeRmSync","names","fs","readdirSync","map","name","fullPath","path","join","stat","statSync","_e","isDirectory","hasObjectAssign","Object","assign","_has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ACrB,EAAE,OAAOK,IAAI;YACX,wCAAwC;YACxC,OAAO;gBAAEN,MAAMA;gBAAMO,aAAa;2BAAM;;YAAM;QAChD;QACA,OAAO;YACLP,MAAMA;YACNO,aAAa;uBAAMH,KAAKG,WAAW;;QACrC;IACF;AACF;AAEA;;;;CAIC,GACD,IAAMC,kBAAkB,OAAOC,OAAOC,MAAM,KAAK;AACjD,IAAMC,kBAAkBF,OAAO1B,SAAS,CAAC6B,cAAc;AAEhD,SAASzC,aAAmB0C,MAAS,EAAEC,MAAS;IACrD,IAAIN,iBAAiB,OAAOC,OAAOC,MAAM,CAACG,QAAQC;IAElD,IAAK,IAAMC,OAAOD,OAAQ;QACxB,IAAIH,gBAAgBK,IAAI,CAACF,QAAQC,MAAM,AAACF,MAAkC,CAACE,IAAI,GAAGD,MAAM,CAACC,IAAI;IAC/F;IACA,OAAOF;AACT"}
|
|
@@ -57,7 +57,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
57
57
|
}
|
|
58
58
|
return newObj;
|
|
59
59
|
}
|
|
60
|
-
var _dirname = _path.default.dirname(typeof
|
|
60
|
+
var _dirname = _path.default.dirname(typeof __filename === 'undefined' ? _url.default.fileURLToPath(require("url").pathToFileURL(__filename).toString()) : __filename);
|
|
61
61
|
var nodeModules = _path.default.join(_dirname, '..', '..', '..', 'node_modules');
|
|
62
62
|
var moduleName = 'node-version-install';
|
|
63
63
|
var cached;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/lib/loadNodeVersionInstall.ts"],"sourcesContent":["import installModule from 'install-module-linked';\nimport type { InstallOptions, InstallResult } from 'node-version-install';\nimport path from 'path';\nimport url from 'url';\n\nconst _dirname = path.dirname(typeof
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/lib/loadNodeVersionInstall.ts"],"sourcesContent":["import installModule from 'install-module-linked';\nimport type { InstallOptions, InstallResult } from 'node-version-install';\nimport path from 'path';\nimport url from 'url';\n\nconst _dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\nconst nodeModules = path.join(_dirname, '..', '..', '..', 'node_modules');\nconst moduleName = 'node-version-install';\n\ntype InstallCallback = (err?: Error, results?: InstallResult[]) => void;\ntype InstallVersionFn = (version: string, options: InstallOptions, callback: InstallCallback) => void;\n\nlet cached: InstallVersionFn | undefined;\n\nfunction loadModule(moduleName, callback) {\n if (typeof require === 'undefined') {\n import(moduleName)\n .then((mod) => {\n callback(null, mod?.default ?? null);\n })\n .catch(callback);\n } else {\n try {\n callback(null, require(moduleName));\n } catch (err) {\n callback(err, null);\n }\n }\n}\n\nexport default function loadNodeVersionInstall(callback: (err: Error | null, installVersion: InstallVersionFn) => void): void {\n if (cached !== undefined) return callback(null, cached);\n\n installModule(moduleName, nodeModules, {}, (err) => {\n if (err) return callback(err, null);\n loadModule(moduleName, (err, _cached: InstallVersionFn) => {\n if (err) return callback(err, null);\n cached = _cached;\n callback(null, cached);\n });\n });\n}\n"],"names":["loadNodeVersionInstall","_dirname","path","dirname","__filename","url","fileURLToPath","nodeModules","join","moduleName","cached","loadModule","callback","require","then","mod","default","catch","err","undefined","installModule","_cached"],"mappings":";;;;+BA8BA;;;eAAwBA;;;0EA9BE;2DAET;0DACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEhB,IAAMC,WAAWC,aAAI,CAACC,OAAO,CAAC,OAAOC,eAAe,cAAcC,YAAG,CAACC,aAAa,CAAC,uDAAmBF;AACvG,IAAMG,cAAcL,aAAI,CAACM,IAAI,CAACP,UAAU,MAAM,MAAM,MAAM;AAC1D,IAAMQ,aAAa;AAKnB,IAAIC;AAEJ,SAASC,WAAWF,UAAU,EAAEG,QAAQ;IACtC,IAAI,OAAOC,YAAY,aAAa;QAClC,gBAAOJ;2DAAP;WACGK,IAAI,CAAC,SAACC;;YACLH,SAAS,cAAMG,gBAAAA,0BAAAA,IAAKC,OAAO,uCAAI;QACjC,GACCC,KAAK,CAACL;IACX,OAAO;QACL,IAAI;YACFA,SAAS,MAAMC,QAAQJ;QACzB,EAAE,OAAOS,KAAK;YACZN,SAASM,KAAK;QAChB;IACF;AACF;AAEe,SAASlB,uBAAuBY,QAAuE;IACpH,IAAIF,WAAWS,WAAW,OAAOP,SAAS,MAAMF;IAEhDU,IAAAA,4BAAa,EAACX,YAAYF,aAAa,CAAC,GAAG,SAACW;QAC1C,IAAIA,KAAK,OAAON,SAASM,KAAK;QAC9BP,WAAWF,YAAY,SAACS,KAAKG;YAC3B,IAAIH,KAAK,OAAON,SAASM,KAAK;YAC9BR,SAASW;YACTT,SAAS,MAAMF;QACjB;IACF;AACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Find a system binary by searching PATH, excluding ~/.nvu/bin
|
|
3
|
+
* Returns the full path to the binary, or null if not found
|
|
4
|
+
*/
|
|
5
|
+
export declare function resolveSystemBinary(name: string): string | null;
|
|
6
|
+
/**
|
|
7
|
+
* Get PATH with ~/.nvu/bin removed
|
|
8
|
+
* Used to create an environment for spawning system commands
|
|
9
|
+
*/
|
|
10
|
+
export declare function getPathWithoutNvuBin(): string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Find a system binary by searching PATH, excluding ~/.nvu/bin
|
|
3
|
+
* Returns the full path to the binary, or null if not found
|
|
4
|
+
*/
|
|
5
|
+
export declare function resolveSystemBinary(name: string): string | null;
|
|
6
|
+
/**
|
|
7
|
+
* Get PATH with ~/.nvu/bin removed
|
|
8
|
+
* Used to create an environment for spawning system commands
|
|
9
|
+
*/
|
|
10
|
+
export declare function getPathWithoutNvuBin(): string;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve system binaries by searching PATH while excluding ~/.nvu/bin
|
|
3
|
+
* This mirrors the Go binary's findSystemBinary() function
|
|
4
|
+
*/ "use strict";
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
function _export(target, all) {
|
|
9
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
_export(exports, {
|
|
15
|
+
get getPathWithoutNvuBin () {
|
|
16
|
+
return getPathWithoutNvuBin;
|
|
17
|
+
},
|
|
18
|
+
get resolveSystemBinary () {
|
|
19
|
+
return resolveSystemBinary;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
var _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
23
|
+
var _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
24
|
+
var _compatts = require("../compat.js");
|
|
25
|
+
function _interop_require_default(obj) {
|
|
26
|
+
return obj && obj.__esModule ? obj : {
|
|
27
|
+
default: obj
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
var isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE);
|
|
31
|
+
var nvuBinDir = _path.default.join((0, _compatts.homedir)(), '.nvu', 'bin');
|
|
32
|
+
/**
|
|
33
|
+
* Check if two paths are equal (case-insensitive on Windows)
|
|
34
|
+
*/ function pathsEqual(a, b) {
|
|
35
|
+
if (isWindows) {
|
|
36
|
+
return a.toLowerCase() === b.toLowerCase();
|
|
37
|
+
}
|
|
38
|
+
return a === b;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Check if a path is within the nvu bin directory
|
|
42
|
+
*/ function isInNvuBin(filePath) {
|
|
43
|
+
try {
|
|
44
|
+
var realPath = _fs.default.realpathSync(filePath);
|
|
45
|
+
return realPath.indexOf(_path.default.join('.nvu', 'bin')) >= 0 || pathsEqual(_path.default.dirname(realPath), nvuBinDir);
|
|
46
|
+
} catch (_e) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function resolveSystemBinary(name) {
|
|
51
|
+
var pathEnv = process.env.PATH || '';
|
|
52
|
+
var pathSep = isWindows ? ';' : ':';
|
|
53
|
+
var dirs = pathEnv.split(pathSep);
|
|
54
|
+
for(var i = 0; i < dirs.length; i++){
|
|
55
|
+
var dir = dirs[i];
|
|
56
|
+
if (!dir) continue;
|
|
57
|
+
// Skip ~/.nvu/bin
|
|
58
|
+
if (pathsEqual(dir, nvuBinDir)) continue;
|
|
59
|
+
// Build candidate path with appropriate extension
|
|
60
|
+
var candidates = isWindows ? [
|
|
61
|
+
_path.default.join(dir, "".concat(name, ".exe")),
|
|
62
|
+
_path.default.join(dir, "".concat(name, ".cmd")),
|
|
63
|
+
_path.default.join(dir, name)
|
|
64
|
+
] : [
|
|
65
|
+
_path.default.join(dir, name)
|
|
66
|
+
];
|
|
67
|
+
for(var j = 0; j < candidates.length; j++){
|
|
68
|
+
var candidate = candidates[j];
|
|
69
|
+
try {
|
|
70
|
+
var stat = _fs.default.statSync(candidate);
|
|
71
|
+
if (!stat.isFile()) continue;
|
|
72
|
+
// Make sure it's not in ~/.nvu/bin (via symlink)
|
|
73
|
+
if (isInNvuBin(candidate)) continue;
|
|
74
|
+
return candidate;
|
|
75
|
+
} catch (_e) {
|
|
76
|
+
// File doesn't exist, continue
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
function getPathWithoutNvuBin() {
|
|
83
|
+
var pathEnv = process.env.PATH || '';
|
|
84
|
+
var pathSep = isWindows ? ';' : ':';
|
|
85
|
+
var dirs = pathEnv.split(pathSep);
|
|
86
|
+
var filtered = [];
|
|
87
|
+
for(var i = 0; i < dirs.length; i++){
|
|
88
|
+
var dir = dirs[i];
|
|
89
|
+
if (!dir) continue;
|
|
90
|
+
if (pathsEqual(dir, nvuBinDir)) continue;
|
|
91
|
+
if (dir.indexOf(_path.default.join('.nvu', 'bin')) >= 0) continue;
|
|
92
|
+
filtered.push(dir);
|
|
93
|
+
}
|
|
94
|
+
return filtered.join(pathSep);
|
|
95
|
+
}
|
|
96
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -0,0 +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 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');\n\n/**\n * Check if two paths are equal (case-insensitive on Windows)\n */\nfunction pathsEqual(a: string, b: string): boolean {\n if (isWindows) {\n return a.toLowerCase() === b.toLowerCase();\n }\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.PATH || '';\n const pathSep = isWindows ? ';' : ':';\n const dirs = pathEnv.split(pathSep);\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.PATH || '';\n const pathSep = isWindows ? ';' : ':';\n const dirs = pathEnv.split(pathSep);\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(pathSep);\n}\n"],"names":["getPathWithoutNvuBin","resolveSystemBinary","isWindows","process","platform","test","env","OSTYPE","nvuBinDir","path","join","homedir","pathsEqual","a","b","toLowerCase","isInNvuBin","filePath","realPath","fs","realpathSync","indexOf","dirname","_e","name","pathEnv","PATH","pathSep","dirs","split","i","length","dir","candidates","j","candidate","stat","statSync","isFile","filtered","push"],"mappings":"AAAA;;;CAGC;;;;;;;;;;;QAwEeA;eAAAA;;QAtCAC;eAAAA;;;yDAjCD;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;AAE/C;;CAEC,GACD,SAASC,WAAWC,CAAS,EAAEC,CAAS;IACtC,IAAIZ,WAAW;QACb,OAAOW,EAAEE,WAAW,OAAOD,EAAEC,WAAW;IAC1C;IACA,OAAOF,MAAMC;AACf;AAEA;;CAEC,GACD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AACoB,IAAI,IAAI;IACpC,IAAMC,UAAUzB,YAAY,MAAM;IAClC,IAAM0B,OAAOH,QAAQI,KAAK,CAACF;IAE3B,IAAMY,WAAqB,EAAE;IAC7B,IAAK,IAAIT,IAAI,GAAGA,IAAIF,KAAKG,MAAM,EAAED,IAAK;QACpC,IAAME,MAAMJ,IAAI,CAACE,EAAE;QACnB,IAAI,CAACE,KAAK;QACV,IAAIpB,WAAWoB,KAAKxB,YAAY;QAChC,IAAIwB,IAAIX,OAAO,CAACZ,aAAI,CAACC,IAAI,CAAC,QAAQ,WAAW,GAAG;QAChD6B,SAASC,IAAI,CAACR;IAChB;IAEA,OAAOO,SAAS7B,IAAI,CAACiB;AACvB"}
|
package/dist/cjs/worker.js
CHANGED
|
@@ -20,64 +20,12 @@ var _spawnterm = require("spawn-term");
|
|
|
20
20
|
var _compatts = require("./compat.js");
|
|
21
21
|
var _constantsts = require("./constants.js");
|
|
22
22
|
var _loadNodeVersionInstallts = /*#__PURE__*/ _interop_require_default(require("./lib/loadNodeVersionInstall.js"));
|
|
23
|
-
|
|
24
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
25
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
26
|
-
return arr2;
|
|
27
|
-
}
|
|
28
|
-
function _array_without_holes(arr) {
|
|
29
|
-
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
30
|
-
}
|
|
31
|
-
function _define_property(obj, key, value) {
|
|
32
|
-
if (key in obj) {
|
|
33
|
-
Object.defineProperty(obj, key, {
|
|
34
|
-
value: value,
|
|
35
|
-
enumerable: true,
|
|
36
|
-
configurable: true,
|
|
37
|
-
writable: true
|
|
38
|
-
});
|
|
39
|
-
} else {
|
|
40
|
-
obj[key] = value;
|
|
41
|
-
}
|
|
42
|
-
return obj;
|
|
43
|
-
}
|
|
23
|
+
var _resolveSystemBinaryts = require("./lib/resolveSystemBinary.js");
|
|
44
24
|
function _interop_require_default(obj) {
|
|
45
25
|
return obj && obj.__esModule ? obj : {
|
|
46
26
|
default: obj
|
|
47
27
|
};
|
|
48
28
|
}
|
|
49
|
-
function _iterable_to_array(iter) {
|
|
50
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
51
|
-
}
|
|
52
|
-
function _non_iterable_spread() {
|
|
53
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
54
|
-
}
|
|
55
|
-
function _object_spread(target) {
|
|
56
|
-
for(var i = 1; i < arguments.length; i++){
|
|
57
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
58
|
-
var ownKeys = Object.keys(source);
|
|
59
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
60
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
61
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
62
|
-
}));
|
|
63
|
-
}
|
|
64
|
-
ownKeys.forEach(function(key) {
|
|
65
|
-
_define_property(target, key, source[key]);
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
return target;
|
|
69
|
-
}
|
|
70
|
-
function _to_consumable_array(arr) {
|
|
71
|
-
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
72
|
-
}
|
|
73
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
74
|
-
if (!o) return;
|
|
75
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
76
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
77
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
78
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
79
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
80
|
-
}
|
|
81
29
|
var isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE);
|
|
82
30
|
var NODE = isWindows ? 'node.exe' : 'node';
|
|
83
31
|
// Parse npm-generated .cmd wrapper to extract the JS script path
|
|
@@ -112,7 +60,7 @@ function resolveCommand(command, args) {
|
|
|
112
60
|
command: NODE,
|
|
113
61
|
args: [
|
|
114
62
|
scriptPath
|
|
115
|
-
].concat(
|
|
63
|
+
].concat(args)
|
|
116
64
|
};
|
|
117
65
|
}
|
|
118
66
|
}
|
|
@@ -123,7 +71,7 @@ function resolveCommand(command, args) {
|
|
|
123
71
|
command: NODE,
|
|
124
72
|
args: [
|
|
125
73
|
binPath
|
|
126
|
-
].concat(
|
|
74
|
+
].concat(args)
|
|
127
75
|
};
|
|
128
76
|
} catch (_e) {
|
|
129
77
|
// Not an npm package bin, use original command
|
|
@@ -134,6 +82,11 @@ function resolveCommand(command, args) {
|
|
|
134
82
|
};
|
|
135
83
|
}
|
|
136
84
|
function worker(versionExpression, command, args, options, callback) {
|
|
85
|
+
// Handle "system" as a special version that uses system binaries directly
|
|
86
|
+
if (versionExpression === 'system') {
|
|
87
|
+
runWithSystemBinaries(command, args, options, callback);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
137
90
|
// Load node-version-install lazily
|
|
138
91
|
(0, _loadNodeVersionInstallts.default)(function(loadErr, installVersion) {
|
|
139
92
|
if (loadErr) return callback(loadErr);
|
|
@@ -143,7 +96,7 @@ function worker(versionExpression, command, args, options, callback) {
|
|
|
143
96
|
callback(new Error("No versions found from expression: ".concat(versionExpression)));
|
|
144
97
|
return;
|
|
145
98
|
}
|
|
146
|
-
var installOptions =
|
|
99
|
+
var installOptions = (0, _compatts.objectAssign)({
|
|
147
100
|
storagePath: _constantsts.storagePath
|
|
148
101
|
}, options);
|
|
149
102
|
var streamingOptions = options;
|
|
@@ -218,4 +171,48 @@ function worker(versionExpression, command, args, options, callback) {
|
|
|
218
171
|
});
|
|
219
172
|
});
|
|
220
173
|
}
|
|
174
|
+
/**
|
|
175
|
+
* Run command using system binaries (bypassing nvu version management)
|
|
176
|
+
* This handles the "system" version specifier
|
|
177
|
+
*/ function runWithSystemBinaries(command, args, options, callback) {
|
|
178
|
+
// Find the system binary for the command
|
|
179
|
+
var systemBinary = (0, _resolveSystemBinaryts.resolveSystemBinary)(command);
|
|
180
|
+
if (!systemBinary) {
|
|
181
|
+
callback(new Error("System ".concat(command, " not found in PATH")));
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
// Create spawn options with PATH excluding ~/.nvu/bin
|
|
185
|
+
// This ensures any child processes also use system binaries
|
|
186
|
+
var cleanPath = (0, _resolveSystemBinaryts.getPathWithoutNvuBin)();
|
|
187
|
+
var spawnOptions = (0, _compatts.objectAssign)({}, options);
|
|
188
|
+
spawnOptions.env = (0, _compatts.objectAssign)({}, process.env);
|
|
189
|
+
spawnOptions.env.PATH = cleanPath;
|
|
190
|
+
spawnOptions.stdio = options.stdio || 'inherit';
|
|
191
|
+
// On Windows, resolve npm bin commands to bypass .cmd wrappers
|
|
192
|
+
var resolved = resolveCommand(command, args);
|
|
193
|
+
// For system, use the resolved system binary path
|
|
194
|
+
var finalCommand = resolved.command === command ? systemBinary : resolved.command;
|
|
195
|
+
var finalArgs = resolved.command === command ? args : resolved.args;
|
|
196
|
+
if (!options.silent) {
|
|
197
|
+
console.log("$ ".concat((0, _spawnterm.formatArguments)([
|
|
198
|
+
finalCommand
|
|
199
|
+
].concat(finalArgs)).join(' ')));
|
|
200
|
+
}
|
|
201
|
+
(0, _crossspawncb.default)(finalCommand, finalArgs, spawnOptions, function(err, res) {
|
|
202
|
+
if (err && err.message && err.message.indexOf('ExperimentalWarning') >= 0) {
|
|
203
|
+
res = err;
|
|
204
|
+
err = null;
|
|
205
|
+
}
|
|
206
|
+
var result = {
|
|
207
|
+
install: null,
|
|
208
|
+
command: command,
|
|
209
|
+
version: 'system',
|
|
210
|
+
error: err,
|
|
211
|
+
result: res
|
|
212
|
+
};
|
|
213
|
+
callback(err, [
|
|
214
|
+
result
|
|
215
|
+
]);
|
|
216
|
+
});
|
|
217
|
+
}
|
|
221
218
|
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
package/dist/cjs/worker.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/worker.ts"],"sourcesContent":["import spawn, { type SpawnOptions } from 'cross-spawn-cb';\nimport fs from 'fs';\nimport resolveVersions, { type VersionOptions } from 'node-resolve-versions';\nimport type { InstallOptions } from 'node-version-install';\nimport { spawnOptions as createSpawnOptions } from 'node-version-utils';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport resolveBin from 'resolve-bin-sync';\nimport spawnStreaming from 'spawn-streaming';\nimport { createSession, formatArguments } from 'spawn-term';\nimport { stringEndsWith } from './compat.ts';\nimport { storagePath } from './constants.ts';\nimport loadNodeVersionInstall from './lib/loadNodeVersionInstall.ts';\n\nimport type { Options, UseCallback, UseOptions, UseResult } from './types.ts';\n\nconst isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE);\nconst NODE = isWindows ? 'node.exe' : 'node';\n\n// Parse npm-generated .cmd wrapper to extract the JS script path\nfunction parseNpmCmdWrapper(cmdPath: string): string | null {\n try {\n const content = fs.readFileSync(cmdPath, 'utf8');\n // Match: \"%_prog%\" \"%dp0%\\node_modules\\...\\cli.js\" %*\n // or: \"%_prog%\" \"%dp0%\\path\\to\\script.js\" %*\n const match = content.match(/\"%_prog%\"\\s+\"?%dp0%\\\\([^\"]+)\"?\\s+%\\*/);\n if (match) {\n const relativePath = match[1];\n const cmdDir = path.dirname(cmdPath);\n return path.join(cmdDir, relativePath);\n }\n } catch (_e) {\n // ignore\n }\n return null;\n}\n\n// On Windows, resolve npm bin commands to their JS entry points to bypass .cmd wrappers\n// This fixes issues with nvm-windows where .cmd wrappers use symlinked node.exe directly\nfunction resolveCommand(command: string, args: string[]): { command: string; args: string[] } {\n if (!isWindows) return { command, args };\n\n // Case 1: Command is a .cmd file path\n if (stringEndsWith(command.toLowerCase(), '.cmd')) {\n const scriptPath = parseNpmCmdWrapper(command);\n if (scriptPath) {\n return { command: NODE, args: [scriptPath, ...args] };\n }\n }\n\n // Case 2: Try to resolve the command as an npm package bin from node_modules\n try {\n const binPath = resolveBin(command);\n return { command: NODE, args: [binPath, ...args] };\n } catch (_e) {\n // Not an npm package bin, use original command\n }\n\n return { command, args };\n}\n\nexport default function worker(versionExpression: string, command: string, args: string[], options: UseOptions, callback: UseCallback): void {\n // Load node-version-install lazily\n loadNodeVersionInstall((loadErr, installVersion) => {\n if (loadErr) return callback(loadErr);\n\n resolveVersions(versionExpression, options as VersionOptions, (err?: Error, versions?: string[]) => {\n if (err) return callback(err);\n if (!versions.length) {\n callback(new Error(`No versions found from expression: ${versionExpression}`));\n return;\n }\n\n const installOptions = { storagePath, ...options } as InstallOptions;\n const streamingOptions = options as Options;\n const results: UseResult[] = [];\n const queue = new Queue(1);\n\n // Create session once for all processes (only if multiple versions)\n const interactive = options.interactive !== false;\n const session = versions.length >= 2 && createSession && !streamingOptions.streaming ? createSession({ header: `${command} ${args.join(' ')}`, showStatusBar: true, interactive }) : null;\n\n versions.forEach((version: string) => {\n queue.defer((cb) => {\n installVersion(version, installOptions, (err, installs) => {\n const install = installs && installs.length === 1 ? installs[0] : null;\n if (err || !install) {\n const error = err || new Error(`Unexpected version results for version ${version}. Install ${JSON.stringify(installs)}`);\n results.push({ install, command, version, error, result: null });\n return cb();\n }\n const spawnOptions = createSpawnOptions(install.installPath, options as SpawnOptions);\n const prefix = install.version;\n\n function next(err?, res?): void {\n if (err && err.message.indexOf('ExperimentalWarning') >= 0) {\n res = err;\n err = null;\n }\n results.push({ install, command, version, error: err, result: res });\n cb();\n }\n\n // On Windows, resolve npm bin commands to bypass .cmd wrappers\n const resolved = resolveCommand(command, args);\n\n if (versions.length < 2) {\n // Show command when running single version (no terminal session, unless silent)\n if (!options.silent) console.log(`$ ${formatArguments([resolved.command].concat(resolved.args)).join(' ')}`);\n return spawn(resolved.command, resolved.args, spawnOptions, next);\n }\n if (session) session.spawn(resolved.command, resolved.args, spawnOptions, { group: prefix, expanded: streamingOptions.expanded }, next);\n else spawnStreaming(resolved.command, resolved.args, spawnOptions, { prefix }, next);\n });\n });\n });\n queue.await((err) => {\n if (session) {\n session.waitAndClose(() => {\n err ? callback(err) : callback(null, results);\n });\n } else {\n err ? callback(err) : callback(null, results);\n }\n });\n });\n });\n}\n"],"names":["worker","isWindows","process","platform","test","env","OSTYPE","NODE","parseNpmCmdWrapper","cmdPath","content","fs","readFileSync","match","relativePath","cmdDir","path","dirname","join","_e","resolveCommand","command","args","stringEndsWith","toLowerCase","scriptPath","binPath","resolveBin","versionExpression","options","callback","loadNodeVersionInstall","loadErr","installVersion","resolveVersions","err","versions","length","Error","installOptions","storagePath","streamingOptions","results","queue","Queue","interactive","session","createSession","streaming","header","showStatusBar","forEach","version","defer","cb","installs","next","res","message","indexOf","push","install","error","result","JSON","stringify","spawnOptions","createSpawnOptions","installPath","prefix","resolved","silent","console","log","formatArguments","concat","spawn","group","expanded","spawnStreaming","await","waitAndClose"],"mappings":";;;;+BA6DA;;;eAAwBA;;;mEA7DiB;yDAC1B;0EACsC;gCAEF;2DAClC;8DACC;qEACK;qEACI;yBACoB;wBAChB;2BACH;+EACO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAInC,IAAMC,YAAYC,QAAQC,QAAQ,KAAK,WAAW,kBAAkBC,IAAI,CAACF,QAAQG,GAAG,CAACC,MAAM;AAC3F,IAAMC,OAAON,YAAY,aAAa;AAEtC,iEAAiE;AACjE,SAASO,mBAAmBC,OAAe;IACzC,IAAI;QACF,IAAMC,UAAUC,WAAE,CAACC,YAAY,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AeC,IAAAA,8BAAkB,EAACN,QAAQO,WAAW,EAAEvC;wBAC7D,IAAMwC,SAASR,QAAQT,OAAO;wBAW9B,+DAA+D;wBAC/D,IAAMkB,WAAWlD,eAAeC,SAASC;wBAEzC,IAAIc,SAASC,MAAM,GAAG,GAAG;4BACvB,gFAAgF;4BAChF,IAAI,CAACR,QAAQ0C,MAAM,EAAEC,QAAQC,GAAG,CAAC,AAAC,KAAwE,OAApEC,IAAAA,0BAAe,EAAC;gCAACJ,SAASjD,OAAO;6BAAC,CAACsD,MAAM,CAACL,SAAShD,IAAI,GAAGJ,IAAI,CAAC;4BACrG,OAAO0D,IAAAA,qBAAK,EAACN,SAASjD,OAAO,EAAEiD,SAAShD,IAAI,EAAE4C,cAAcV;wBAC9D;wBACA,IAAIV,SAASA,QAAQ8B,KAAK,CAACN,SAASjD,OAAO,EAAEiD,SAAShD,IAAI,EAAE4C,cAAc;4BAAEW,OAAOR;4BAAQS,UAAUrC,iBAAiBqC,QAAQ;wBAAC,GAAGtB;6BAC7HuB,IAAAA,uBAAc,EAACT,SAASjD,OAAO,EAAEiD,SAAShD,IAAI,EAAE4C,cAAc;4BAAEG,QAAAA;wBAAO,GAAGb;oBACjF;gBACF;YACF;YACAb,MAAMqC,KAAK,CAAC,SAAC7C;gBACX,IAAIW,SAAS;oBACXA,QAAQmC,YAAY,CAAC;wBACnB9C,MAAML,SAASK,OAAOL,SAAS,MAAMY;oBACvC;gBACF,OAAO;oBACLP,MAAML,SAASK,OAAOL,SAAS,MAAMY;gBACvC;YACF;QACF;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/worker.ts"],"sourcesContent":["import spawn, { type SpawnOptions } from 'cross-spawn-cb';\nimport fs from 'fs';\nimport resolveVersions, { type VersionOptions } from 'node-resolve-versions';\nimport type { InstallOptions } from 'node-version-install';\nimport { spawnOptions as createSpawnOptions } from 'node-version-utils';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport resolveBin from 'resolve-bin-sync';\nimport spawnStreaming from 'spawn-streaming';\nimport { createSession, formatArguments } from 'spawn-term';\nimport { objectAssign, stringEndsWith } from './compat.ts';\nimport { storagePath } from './constants.ts';\nimport loadNodeVersionInstall from './lib/loadNodeVersionInstall.ts';\nimport { getPathWithoutNvuBin, resolveSystemBinary } from './lib/resolveSystemBinary.ts';\n\nimport type { Options, UseCallback, UseOptions, UseResult } from './types.ts';\n\nconst isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE);\nconst NODE = isWindows ? 'node.exe' : 'node';\n\n// Parse npm-generated .cmd wrapper to extract the JS script path\nfunction parseNpmCmdWrapper(cmdPath: string): string | null {\n try {\n const content = fs.readFileSync(cmdPath, 'utf8');\n // Match: \"%_prog%\" \"%dp0%\\node_modules\\...\\cli.js\" %*\n // or: \"%_prog%\" \"%dp0%\\path\\to\\script.js\" %*\n const match = content.match(/\"%_prog%\"\\s+\"?%dp0%\\\\([^\"]+)\"?\\s+%\\*/);\n if (match) {\n const relativePath = match[1];\n const cmdDir = path.dirname(cmdPath);\n return path.join(cmdDir, relativePath);\n }\n } catch (_e) {\n // ignore\n }\n return null;\n}\n\n// On Windows, resolve npm bin commands to their JS entry points to bypass .cmd wrappers\n// This fixes issues with nvm-windows where .cmd wrappers use symlinked node.exe directly\nfunction resolveCommand(command: string, args: string[]): { command: string; args: string[] } {\n if (!isWindows) return { command, args };\n\n // Case 1: Command is a .cmd file path\n if (stringEndsWith(command.toLowerCase(), '.cmd')) {\n const scriptPath = parseNpmCmdWrapper(command);\n if (scriptPath) {\n return { command: NODE, args: [scriptPath].concat(args) };\n }\n }\n\n // Case 2: Try to resolve the command as an npm package bin from node_modules\n try {\n const binPath = resolveBin(command);\n return { command: NODE, args: [binPath].concat(args) };\n } catch (_e) {\n // Not an npm package bin, use original command\n }\n\n return { command, args };\n}\n\nexport default function worker(versionExpression: string, command: string, args: string[], options: UseOptions, callback: UseCallback): void {\n // Handle \"system\" as a special version that uses system binaries directly\n if (versionExpression === 'system') {\n runWithSystemBinaries(command, args, options, callback);\n return;\n }\n\n // Load node-version-install lazily\n loadNodeVersionInstall((loadErr, installVersion) => {\n if (loadErr) return callback(loadErr);\n\n resolveVersions(versionExpression, options as VersionOptions, (err?: Error, versions?: string[]) => {\n if (err) return callback(err);\n if (!versions.length) {\n callback(new Error(`No versions found from expression: ${versionExpression}`));\n return;\n }\n\n const installOptions = objectAssign({ storagePath: storagePath }, options) as InstallOptions;\n const streamingOptions = options as Options;\n const results: UseResult[] = [];\n const queue = new Queue(1);\n\n // Create session once for all processes (only if multiple versions)\n const interactive = options.interactive !== false;\n const session = versions.length >= 2 && createSession && !streamingOptions.streaming ? createSession({ header: `${command} ${args.join(' ')}`, showStatusBar: true, interactive }) : null;\n\n versions.forEach((version: string) => {\n queue.defer((cb) => {\n installVersion(version, installOptions, (err, installs) => {\n const install = installs && installs.length === 1 ? installs[0] : null;\n if (err || !install) {\n const error = err || new Error(`Unexpected version results for version ${version}. Install ${JSON.stringify(installs)}`);\n results.push({ install, command, version, error, result: null });\n return cb();\n }\n const spawnOptions = createSpawnOptions(install.installPath, options as SpawnOptions);\n const prefix = install.version;\n\n function next(err?, res?): void {\n if (err && err.message.indexOf('ExperimentalWarning') >= 0) {\n res = err;\n err = null;\n }\n results.push({ install, command, version, error: err, result: res });\n cb();\n }\n\n // On Windows, resolve npm bin commands to bypass .cmd wrappers\n const resolved = resolveCommand(command, args);\n\n if (versions.length < 2) {\n // Show command when running single version (no terminal session, unless silent)\n if (!options.silent) console.log(`$ ${formatArguments([resolved.command].concat(resolved.args)).join(' ')}`);\n return spawn(resolved.command, resolved.args, spawnOptions, next);\n }\n if (session) session.spawn(resolved.command, resolved.args, spawnOptions, { group: prefix, expanded: streamingOptions.expanded }, next);\n else spawnStreaming(resolved.command, resolved.args, spawnOptions, { prefix }, next);\n });\n });\n });\n queue.await((err) => {\n if (session) {\n session.waitAndClose(() => {\n err ? callback(err) : callback(null, results);\n });\n } else {\n err ? callback(err) : callback(null, results);\n }\n });\n });\n });\n}\n\n/**\n * Run command using system binaries (bypassing nvu version management)\n * This handles the \"system\" version specifier\n */\nfunction runWithSystemBinaries(command: string, args: string[], options: UseOptions, callback: UseCallback): void {\n // Find the system binary for the command\n const systemBinary = resolveSystemBinary(command);\n if (!systemBinary) {\n callback(new Error(`System ${command} not found in PATH`));\n return;\n }\n\n // Create spawn options with PATH excluding ~/.nvu/bin\n // This ensures any child processes also use system binaries\n const cleanPath = getPathWithoutNvuBin();\n const spawnOptions: SpawnOptions = objectAssign({}, options as SpawnOptions);\n spawnOptions.env = objectAssign({}, process.env);\n spawnOptions.env.PATH = cleanPath;\n spawnOptions.stdio = options.stdio || 'inherit';\n\n // On Windows, resolve npm bin commands to bypass .cmd wrappers\n const resolved = resolveCommand(command, args);\n\n // For system, use the resolved system binary path\n const finalCommand = resolved.command === command ? systemBinary : resolved.command;\n const finalArgs = resolved.command === command ? args : resolved.args;\n\n if (!options.silent) {\n console.log(`$ ${formatArguments([finalCommand].concat(finalArgs)).join(' ')}`);\n }\n\n spawn(finalCommand, finalArgs, spawnOptions, (err?, res?) => {\n if (err && err.message && err.message.indexOf('ExperimentalWarning') >= 0) {\n res = err;\n err = null;\n }\n\n const result: UseResult = {\n install: null,\n command,\n version: 'system',\n error: err,\n result: res,\n };\n\n callback(err, [result]);\n });\n}\n"],"names":["worker","isWindows","process","platform","test","env","OSTYPE","NODE","parseNpmCmdWrapper","cmdPath","content","fs","readFileSync","match","relativePath","cmdDir","path","dirname","join","_e","resolveCommand","command","args","stringEndsWith","toLowerCase","scriptPath","concat","binPath","resolveBin","versionExpression","options","callback","runWithSystemBinaries","loadNodeVersionInstall","loadErr","installVersion","resolveVersions","err","versions","length","Error","installOptions","objectAssign","storagePath","streamingOptions","results","queue","Queue","interactive","session","createSession","streaming","header","showStatusBar","forEach","version","defer","cb","installs","next","res","message","indexOf","push","install","error","result","JSON","stringify","spawnOptions","createSpawnOptions","installPath","prefix","resolved","silent","console","log","formatArguments","spawn","group","expanded","spawnStreaming","await","waitAndClose","systemBinary","resolveSystemBinary","cleanPath","getPathWithoutNvuBin","PATH","stdio","finalCommand","finalArgs"],"mappings":";;;;+BA8DA;;;eAAwBA;;;mEA9DiB;yDAC1B;0EACsC;gCAEF;2DAClC;8DACC;qEACK;qEACI;yBACoB;wBACF;2BACjB;+EACO;qCACuB;;;;;;AAI1D,IAAMC,YAAYC,QAAQC,QAAQ,KAAK,WAAW,kBAAkBC,IAAI,CAACF,QAAQG,GAAG,CAACC,MAAM;AAC3F,IAAMC,OAAON,YAAY,aAAa;AAEtC,iEAAiE;AACjE,SAASO,mBAAmBC,OAAe;IACzC,IAAI;QACF,IAAMC,UAAUC,WAAE,CAACC,YAAY,CAACH,SAAS;QACzC,uDAAuD;QACvD,8CAA8C;QAC9C,IAAMI,QAAQH,QAAQG,KAAK,CAAC;QAC5B,IAAIA,OAAO;YACT,IAAMC,eAAeD,KAAK,CAAC,EAAE;YAC7B,IAAME,SAASC,aAAI,CAACC,OAAO,CAACR;YAC5B,OAAOO,aAAI,CAACE,IAAI,CAACH,QAAQD;QAC3B;IACF,EAAE,OAAOK,IAAI;IACX,SAAS;IACX;IACA,OAAO;AACT;AAEA,wFAAwF;AACxF,yFAAyF;AACzF,SAASC,eAAeC,OAAe,EAAEC,IAAc;IACrD,IAAI,CAACrB,WAAW,OAAO;QAAEoB,SAAAA;QAASC,MAAAA;IAAK;IAEvC,sCAAsC;IACtC,IAAIC,IAAAA,wBAAc,EAACF,QAAQG,WAAW,IAAI,SAAS;QACjD,IAAMC,aAAajB,mBAAmBa;QACtC,IAAII,YAAY;YACd,OAAO;gBAAEJ,SAASd;gBAAMe,MAAM;oBAACG;iBAAW,CAACC,MAAM,CAACJ;YAAM;QAC1D;IACF;IAEA,6EAA6E;IAC7E,IAAI;QACF,IAAMK,UAAUC,IAAAA,uBAAU,EAACP;QAC3B,OAAO;YAAEA,SAASd;YAAMe,MAAM;gBAACK;aAAQ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CAAC;IAC1E;IAEA4D,IAAAA,qBAAK,EAACY,cAAcC,WAAWtB,cAAc,SAAChC,KAAMuB;QAClD,IAAIvB,OAAOA,IAAIwB,OAAO,IAAIxB,IAAIwB,OAAO,CAACC,OAAO,CAAC,0BAA0B,GAAG;YACzEF,MAAMvB;YACNA,MAAM;QACR;QAEA,IAAM6B,SAAoB;YACxBF,SAAS;YACT3C,SAAAA;YACAkC,SAAS;YACTU,OAAO5B;YACP6B,QAAQN;QACV;QAEA7B,SAASM,KAAK;YAAC6B;SAAO;IACxB;AACF"}
|
|
@@ -3,6 +3,7 @@ import fs from 'fs';
|
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { storagePath } from '../constants.js';
|
|
5
5
|
import { findInstalledVersions } from '../lib/findInstalledVersions.js';
|
|
6
|
+
import { resolveSystemBinary } from '../lib/resolveSystemBinary.js';
|
|
6
7
|
/**
|
|
7
8
|
* nvu which
|
|
8
9
|
*
|
|
@@ -21,6 +22,20 @@ import { findInstalledVersions } from '../lib/findInstalledVersions.js';
|
|
|
21
22
|
exit(1);
|
|
22
23
|
return;
|
|
23
24
|
}
|
|
25
|
+
// Handle "system" version specially
|
|
26
|
+
if (version === 'system') {
|
|
27
|
+
console.log('Version: system');
|
|
28
|
+
console.log(`Source: ${getVersionSource(cwd)}`);
|
|
29
|
+
const systemNode = resolveSystemBinary('node');
|
|
30
|
+
console.log(`Binary: ${systemNode || 'not found'}`);
|
|
31
|
+
if (systemNode) {
|
|
32
|
+
console.log('Status: Available');
|
|
33
|
+
} else {
|
|
34
|
+
console.log('Status: Not found (install Node.js on your system)');
|
|
35
|
+
}
|
|
36
|
+
exit(0);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
24
39
|
// Resolve partial version to exact installed version
|
|
25
40
|
const versionsPath = path.join(storagePath, 'installed');
|
|
26
41
|
const matches = findInstalledVersions(versionsPath, version);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/which.ts"],"sourcesContent":["import exit from 'exit-compat';\nimport fs from 'fs';\nimport path from 'path';\nimport { storagePath } from '../constants.ts';\nimport { findInstalledVersions } from '../lib/findInstalledVersions.ts';\n\n/**\n * nvu which\n *\n * Show which Node binary would be used based on current directory.\n * This simulates what the nvu binary would do.\n */\nexport default function whichCmd(_args: string[]): void {\n const cwd = process.cwd();\n\n // Resolve version using the same logic as the nvu binary\n const version = resolveVersion(cwd);\n\n if (!version) {\n console.log('No Node version configured for this directory.');\n console.log('');\n console.log('To configure a version:');\n console.log(' nvu local <version> - Set version for this project');\n console.log(' nvu default <version> - Set global default');\n exit(1);\n return;\n }\n\n // Resolve partial version to exact installed version\n const versionsPath = path.join(storagePath, 'installed');\n const matches = findInstalledVersions(versionsPath, version);\n const resolvedVersion = matches.length > 0 ? matches[matches.length - 1] : null;\n\n // Display version (show resolution if different)\n if (resolvedVersion && resolvedVersion !== version && resolvedVersion !== `v${version}`) {\n console.log(`Version: ${version} \\u2192 ${resolvedVersion}`);\n } else {\n console.log(`Version: ${resolvedVersion || version}`);\n }\n console.log(`Source: ${getVersionSource(cwd)}`);\n\n if (resolvedVersion) {\n const actualVersionPath = path.join(versionsPath, resolvedVersion);\n const nodePath = path.join(actualVersionPath, 'bin', 'node');\n console.log(`Binary: ${nodePath}`);\n if (fs.existsSync(nodePath)) {\n console.log('Status: Installed');\n } else {\n console.log('Status: Directory exists but binary not found');\n }\n } else {\n console.log(`Status: Not installed (run: nvu install ${version})`);\n }\n\n exit(0);\n}\n\n/**\n * Resolve version from config files (mirrors nvu binary logic)\n */\nfunction resolveVersion(cwd: string): string | null {\n // Walk up directories looking for .nvurc or .nvmrc\n let dir = cwd;\n while (true) {\n // Check .nvurc first\n const nvurcPath = path.join(dir, '.nvurc');\n if (fs.existsSync(nvurcPath)) {\n return fs.readFileSync(nvurcPath, 'utf8').trim();\n }\n\n // Check .nvmrc\n const nvmrcPath = path.join(dir, '.nvmrc');\n if (fs.existsSync(nvmrcPath)) {\n return fs.readFileSync(nvmrcPath, 'utf8').trim();\n }\n\n // Move to parent\n const parent = path.dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n\n // Check global default\n const defaultPath = path.join(storagePath, 'default');\n if (fs.existsSync(defaultPath)) {\n return fs.readFileSync(defaultPath, 'utf8').trim();\n }\n\n return null;\n}\n\n/**\n * Determine the source of the version (for display)\n */\nfunction getVersionSource(cwd: string): string {\n let dir = cwd;\n while (true) {\n const nvurcPath = path.join(dir, '.nvurc');\n if (fs.existsSync(nvurcPath)) {\n return nvurcPath;\n }\n\n const nvmrcPath = path.join(dir, '.nvmrc');\n if (fs.existsSync(nvmrcPath)) {\n return nvmrcPath;\n }\n\n const parent = path.dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n\n const defaultPath = path.join(storagePath, 'default');\n if (fs.existsSync(defaultPath)) {\n return `${defaultPath} (global default)`;\n }\n\n return 'none';\n}\n"],"names":["exit","fs","path","storagePath","findInstalledVersions","whichCmd","_args","cwd","process","version","resolveVersion","console","log","versionsPath","join","matches","resolvedVersion","length","
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/which.ts"],"sourcesContent":["import exit from 'exit-compat';\nimport fs from 'fs';\nimport path from 'path';\nimport { storagePath } from '../constants.ts';\nimport { findInstalledVersions } from '../lib/findInstalledVersions.ts';\nimport { resolveSystemBinary } from '../lib/resolveSystemBinary.ts';\n\n/**\n * nvu which\n *\n * Show which Node binary would be used based on current directory.\n * This simulates what the nvu binary would do.\n */\nexport default function whichCmd(_args: string[]): void {\n const cwd = process.cwd();\n\n // Resolve version using the same logic as the nvu binary\n const version = resolveVersion(cwd);\n\n if (!version) {\n console.log('No Node version configured for this directory.');\n console.log('');\n console.log('To configure a version:');\n console.log(' nvu local <version> - Set version for this project');\n console.log(' nvu default <version> - Set global default');\n exit(1);\n return;\n }\n\n // Handle \"system\" version specially\n if (version === 'system') {\n console.log('Version: system');\n console.log(`Source: ${getVersionSource(cwd)}`);\n const systemNode = resolveSystemBinary('node');\n console.log(`Binary: ${systemNode || 'not found'}`);\n if (systemNode) {\n console.log('Status: Available');\n } else {\n console.log('Status: Not found (install Node.js on your system)');\n }\n exit(0);\n return;\n }\n\n // Resolve partial version to exact installed version\n const versionsPath = path.join(storagePath, 'installed');\n const matches = findInstalledVersions(versionsPath, version);\n const resolvedVersion = matches.length > 0 ? matches[matches.length - 1] : null;\n\n // Display version (show resolution if different)\n if (resolvedVersion && resolvedVersion !== version && resolvedVersion !== `v${version}`) {\n console.log(`Version: ${version} \\u2192 ${resolvedVersion}`);\n } else {\n console.log(`Version: ${resolvedVersion || version}`);\n }\n console.log(`Source: ${getVersionSource(cwd)}`);\n\n if (resolvedVersion) {\n const actualVersionPath = path.join(versionsPath, resolvedVersion);\n const nodePath = path.join(actualVersionPath, 'bin', 'node');\n console.log(`Binary: ${nodePath}`);\n if (fs.existsSync(nodePath)) {\n console.log('Status: Installed');\n } else {\n console.log('Status: Directory exists but binary not found');\n }\n } else {\n console.log(`Status: Not installed (run: nvu install ${version})`);\n }\n\n exit(0);\n}\n\n/**\n * Resolve version from config files (mirrors nvu binary logic)\n */\nfunction resolveVersion(cwd: string): string | null {\n // Walk up directories looking for .nvurc or .nvmrc\n let dir = cwd;\n while (true) {\n // Check .nvurc first\n const nvurcPath = path.join(dir, '.nvurc');\n if (fs.existsSync(nvurcPath)) {\n return fs.readFileSync(nvurcPath, 'utf8').trim();\n }\n\n // Check .nvmrc\n const nvmrcPath = path.join(dir, '.nvmrc');\n if (fs.existsSync(nvmrcPath)) {\n return fs.readFileSync(nvmrcPath, 'utf8').trim();\n }\n\n // Move to parent\n const parent = path.dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n\n // Check global default\n const defaultPath = path.join(storagePath, 'default');\n if (fs.existsSync(defaultPath)) {\n return fs.readFileSync(defaultPath, 'utf8').trim();\n }\n\n return null;\n}\n\n/**\n * Determine the source of the version (for display)\n */\nfunction getVersionSource(cwd: string): string {\n let dir = cwd;\n while (true) {\n const nvurcPath = path.join(dir, '.nvurc');\n if (fs.existsSync(nvurcPath)) {\n return nvurcPath;\n }\n\n const nvmrcPath = path.join(dir, '.nvmrc');\n if (fs.existsSync(nvmrcPath)) {\n return nvmrcPath;\n }\n\n const parent = path.dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n\n const defaultPath = path.join(storagePath, 'default');\n if (fs.existsSync(defaultPath)) {\n return `${defaultPath} (global default)`;\n }\n\n return 'none';\n}\n"],"names":["exit","fs","path","storagePath","findInstalledVersions","resolveSystemBinary","whichCmd","_args","cwd","process","version","resolveVersion","console","log","getVersionSource","systemNode","versionsPath","join","matches","resolvedVersion","length","actualVersionPath","nodePath","existsSync","dir","nvurcPath","readFileSync","trim","nvmrcPath","parent","dirname","defaultPath"],"mappings":"AAAA,OAAOA,UAAU,cAAc;AAC/B,OAAOC,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AACxB,SAASC,WAAW,QAAQ,kBAAkB;AAC9C,SAASC,qBAAqB,QAAQ,kCAAkC;AACxE,SAASC,mBAAmB,QAAQ,gCAAgC;AAEpE;;;;;CAKC,GACD,eAAe,SAASC,SAASC,KAAe;IAC9C,MAAMC,MAAMC,QAAQD,GAAG;IAEvB,yDAAyD;IACzD,MAAME,UAAUC,eAAeH;IAE/B,IAAI,CAACE,SAAS;QACZE,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZb,KAAK;QACL;IACF;IAEA,oCAAoC;IACpC,IAAIU,YAAY,UAAU;QACxBE,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC,CAAC,QAAQ,EAAEC,iBAAiBN,MAAM;QAC9C,MAAMO,aAAaV,oBAAoB;QACvCO,QAAQC,GAAG,CAAC,CAAC,QAAQ,EAAEE,cAAc,aAAa;QAClD,IAAIA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;QAChD;QAEA,eAAe;QACf,MAAMC,YAAY1B,KAAKe,IAAI,CAACO,KAAK;QACjC,IAAIvB,GAAGsB,UAAU,CAACK,YAAY;YAC5B,OAAO3B,GAAGyB,YAAY,CAACE,WAAW,QAAQD,IAAI;QAChD;QAEA,iBAAiB;QACjB,MAAME,SAAS3B,KAAK4B,OAAO,CAACN;QAC5B,IAAIK,WAAWL,KAAK;QACpBA,MAAMK;IACR;IAEA,uBAAuB;IACvB,MAAME,cAAc7B,KAAKe,IAAI,CAACd,aAAa;IAC3C,IAAIF,GAAGsB,UAAU,CAACQ,cAAc;QAC9B,OAAO9B,GAAGyB,YAAY,CAACK,aAAa,QAAQJ,IAAI;IAClD;IAEA,OAAO;AACT;AAEA;;CAEC,GACD,SAASb,iBAAiBN,GAAW;IACnC,IAAIgB,MAAMhB;IACV,MAAO,KAAM;QACX,MAAMiB,YAAYvB,KAAKe,IAAI,CAACO,KAAK;QACjC,IAAIvB,GAAGsB,UAAU,CAACE,YAAY;YAC5B,OAAOA;QACT;QAEA,MAAMG,YAAY1B,KAAKe,IAAI,CAACO,KAAK;QACjC,IAAIvB,GAAGsB,UAAU,CAACK,YAAY;YAC5B,OAAOA;QACT;QAEA,MAAMC,SAAS3B,KAAK4B,OAAO,CAACN;QAC5B,IAAIK,WAAWL,KAAK;QACpBA,MAAMK;IACR;IAEA,MAAME,cAAc7B,KAAKe,IAAI,CAACd,aAAa;IAC3C,IAAIF,GAAGsB,UAAU,CAACQ,cAAc;QAC9B,OAAO,GAAGA,YAAY,iBAAiB,CAAC;IAC1C;IAEA,OAAO;AACT"}
|
package/dist/esm/compat.d.ts
CHANGED
package/dist/esm/compat.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* Compatibility Layer for Node.js 0.8+
|
|
3
3
|
* Local to this package - contains only needed functions.
|
|
4
4
|
*/ import fs from 'fs';
|
|
5
|
-
import
|
|
5
|
+
import Module from 'module';
|
|
6
6
|
import os from 'os';
|
|
7
7
|
import path from 'path';
|
|
8
8
|
// Use existing require in CJS, or createRequire in ESM (Node 12.2+)
|
|
9
|
-
const _require = typeof require === 'undefined' ?
|
|
9
|
+
const _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;
|
|
10
10
|
export function homedir() {
|
|
11
11
|
return typeof os.homedir === 'function' ? os.homedir() : require('homedir-polyfill')();
|
|
12
12
|
}
|
|
@@ -19,9 +19,7 @@ export function tmpdir() {
|
|
|
19
19
|
* - Falls back to lastIndexOf on Node 0.8-3.x
|
|
20
20
|
*/ const hasEndsWith = typeof String.prototype.endsWith === 'function';
|
|
21
21
|
export function stringEndsWith(str, search, position) {
|
|
22
|
-
if (hasEndsWith)
|
|
23
|
-
return str.endsWith(search, position);
|
|
24
|
-
}
|
|
22
|
+
if (hasEndsWith) return str.endsWith(search, position);
|
|
25
23
|
const len = position === undefined ? str.length : position;
|
|
26
24
|
return str.lastIndexOf(search) === len - search.length;
|
|
27
25
|
}
|
|
@@ -57,3 +55,16 @@ export function readdirWithTypes(dir) {
|
|
|
57
55
|
};
|
|
58
56
|
});
|
|
59
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Object.assign wrapper for Node.js 0.8+
|
|
60
|
+
* - Uses native Object.assign on Node 4.0+
|
|
61
|
+
* - Falls back to manual property copy on Node 0.8-3.x
|
|
62
|
+
*/ const hasObjectAssign = typeof Object.assign === 'function';
|
|
63
|
+
const _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
64
|
+
export function objectAssign(target, source) {
|
|
65
|
+
if (hasObjectAssign) return Object.assign(target, source);
|
|
66
|
+
for(const key in source){
|
|
67
|
+
if (_hasOwnProperty.call(source, key)) target[key] = source[key];
|
|
68
|
+
}
|
|
69
|
+
return target;
|
|
70
|
+
}
|
package/dist/esm/compat.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/compat.ts"],"sourcesContent":["/**\n * Compatibility Layer for Node.js 0.8+\n * Local to this package - contains only needed functions.\n */\nimport fs from 'fs';\nimport
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/compat.ts"],"sourcesContent":["/**\n * Compatibility Layer for Node.js 0.8+\n * Local to this package - contains only needed functions.\n */\nimport fs from 'fs';\nimport Module from 'module';\nimport os from 'os';\nimport path from 'path';\n\n// Use existing require in CJS, or createRequire in ESM (Node 12.2+)\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\nexport function homedir(): string {\n return typeof os.homedir === 'function' ? os.homedir() : require('homedir-polyfill')();\n}\n\nexport function tmpdir(): string {\n return typeof os.tmpdir === 'function' ? os.tmpdir() : require('os-shim').tmpdir();\n}\n\n/**\n * String.prototype.endsWith wrapper for Node.js 0.8+\n * - Uses native endsWith on Node 4.0+ / ES2015+\n * - Falls back to lastIndexOf on Node 0.8-3.x\n */\nconst hasEndsWith = typeof String.prototype.endsWith === 'function';\nexport function stringEndsWith(str: string, search: string, position?: number): boolean {\n if (hasEndsWith) return str.endsWith(search, position);\n const len = position === undefined ? str.length : position;\n return str.lastIndexOf(search) === len - search.length;\n}\n\n/**\n * Recursive mkdir for Node.js 0.8+\n */\nexport function mkdirpSync(dir: string): void {\n const mkdirp = _require('mkdirp-classic');\n mkdirp.sync(dir);\n}\n\n/**\n * Recursive rm for Node.js 0.8+\n */\nexport function rmSync(dir: string): void {\n const safeRmSync = _require('fs-remove-compat').safeRmSync;\n safeRmSync(dir);\n}\n\n/**\n * Read directory entries with types for Node.js 0.8+\n * Returns array of {name, isDirectory()}\n */\nexport interface DirEntry {\n name: string;\n isDirectory(): boolean;\n}\n\nexport function readdirWithTypes(dir: string): DirEntry[] {\n const names = fs.readdirSync(dir);\n return names.map((name) => {\n const fullPath = path.join(dir, name);\n let stat: fs.Stats;\n try {\n stat = fs.statSync(fullPath);\n } catch (_e) {\n // If stat fails, treat as non-directory\n return { name: name, isDirectory: () => false };\n }\n return {\n name: name,\n isDirectory: () => stat.isDirectory(),\n };\n });\n}\n\n/**\n * Object.assign wrapper for Node.js 0.8+\n * - Uses native Object.assign on Node 4.0+\n * - Falls back to manual property copy on Node 0.8-3.x\n */\nconst hasObjectAssign = typeof Object.assign === 'function';\nconst _hasOwnProperty = Object.prototype.hasOwnProperty;\n\nexport function objectAssign<T, U>(target: T, source: U): T & U {\n if (hasObjectAssign) return Object.assign(target, source);\n\n for (const key in source) {\n if (_hasOwnProperty.call(source, key)) (target as Record<string, unknown>)[key] = source[key];\n }\n return target as T & U;\n}\n"],"names":["fs","Module","os","path","_require","require","createRequire","url","homedir","tmpdir","hasEndsWith","String","prototype","endsWith","stringEndsWith","str","search","position","len","undefined","length","lastIndexOf","mkdirpSync","dir","mkdirp","sync","rmSync","safeRmSync","readdirWithTypes","names","readdirSync","map","name","fullPath","join","stat","statSync","_e","isDirectory","hasObjectAssign","Object","assign","_hasOwnProperty","hasOwnProperty","objectAssign","target","source","key","call"],"mappings":"AAAA;;;CAGC,GACD,OAAOA,QAAQ,KAAK;AACpB,OAAOC,YAAY,SAAS;AAC5B,OAAOC,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AAExB,oEAAoE;AACpE,MAAMC,WAAW,OAAOC,YAAY,cAAcJ,OAAOK,aAAa,CAAC,YAAYC,GAAG,IAAIF;AAE1F,OAAO,SAASG;IACd,OAAO,OAAON,GAAGM,OAAO,KAAK,aAAaN,GAAGM,OAAO,KAAKH,QAAQ;AACnE;AAEA,OAAO,SAASI;IACd,OAAO,OAAOP,GAAGO,MAAM,KAAK,aAAaP,GAAGO,MAAM,KAAKJ,QAAQ,WAAWI,MAAM;AAClF;AAEA;;;;CAIC,GACD,MAAMC,cAAc,OAAOC,OAAOC,SAAS,CAACC,QAAQ,KAAK;AACzD,OAAO,SAASC,eAAeC,GAAW,EAAEC,MAAc,EAAEC,QAAiB;IAC3E,IAAIP,aAAa,OAAOK,IAAIF,QAAQ,CAACG,QAAQC;IAC7C,MAAMC,MAAMD,aAAaE,YAAYJ,IAAIK,MAAM,GAAGH;IAClD,OAAOF,IAAIM,WAAW,CAACL,YAAYE,MAAMF,OAAOI,MAAM;AACxD;AAEA;;CAEC,GACD,OAAO,SAASE,WAAWC,GAAW;IACpC,MAAMC,SAASpB,SAAS;IACxBoB,OAAOC,IAAI,CAACF;AACd;AAEA;;CAEC,GACD,OAAO,SAASG,OAAOH,GAAW;IAChC,MAAMI,aAAavB,SAAS,oBAAoBuB,UAAU;IAC1DA,WAAWJ;AACb;AAWA,OAAO,SAASK,iBAAiBL,GAAW;IAC1C,MAAMM,QAAQ7B,GAAG8B,WAAW,CAACP;IAC7B,OAAOM,MAAME,GAAG,CAAC,CAACC;QAChB,MAAMC,WAAW9B,KAAK+B,IAAI,CAACX,KAAKS;QAChC,IAAIG;QACJ,IAAI;YACFA,OAAOnC,GAAGoC,QAAQ,CAACH;QACrB,EAAE,OAAOI,IAAI;YACX,wCAAwC;YACxC,OAAO;gBAAEL,MAAMA;gBAAMM,aAAa,IAAM;YAAM;QAChD;QACA,OAAO;YACLN,MAAMA;YACNM,aAAa,IAAMH,KAAKG,WAAW;QACrC;IACF;AACF;AAEA;;;;CAIC,GACD,MAAMC,kBAAkB,OAAOC,OAAOC,MAAM,KAAK;AACjD,MAAMC,kBAAkBF,OAAO5B,SAAS,CAAC+B,cAAc;AAEvD,OAAO,SAASC,aAAmBC,MAAS,EAAEC,MAAS;IACrD,IAAIP,iBAAiB,OAAOC,OAAOC,MAAM,CAACI,QAAQC;IAElD,IAAK,MAAMC,OAAOD,OAAQ;QACxB,IAAIJ,gBAAgBM,IAAI,CAACF,QAAQC,MAAM,AAACF,MAAkC,CAACE,IAAI,GAAGD,MAAM,CAACC,IAAI;IAC/F;IACA,OAAOF;AACT"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import installModule from 'install-module-linked';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import url from 'url';
|
|
4
|
-
const _dirname = path.dirname(typeof
|
|
4
|
+
const _dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);
|
|
5
5
|
const nodeModules = path.join(_dirname, '..', '..', '..', 'node_modules');
|
|
6
6
|
const moduleName = 'node-version-install';
|
|
7
7
|
let cached;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/lib/loadNodeVersionInstall.ts"],"sourcesContent":["import installModule from 'install-module-linked';\nimport type { InstallOptions, InstallResult } from 'node-version-install';\nimport path from 'path';\nimport url from 'url';\n\nconst _dirname = path.dirname(typeof
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/lib/loadNodeVersionInstall.ts"],"sourcesContent":["import installModule from 'install-module-linked';\nimport type { InstallOptions, InstallResult } from 'node-version-install';\nimport path from 'path';\nimport url from 'url';\n\nconst _dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\nconst nodeModules = path.join(_dirname, '..', '..', '..', 'node_modules');\nconst moduleName = 'node-version-install';\n\ntype InstallCallback = (err?: Error, results?: InstallResult[]) => void;\ntype InstallVersionFn = (version: string, options: InstallOptions, callback: InstallCallback) => void;\n\nlet cached: InstallVersionFn | undefined;\n\nfunction loadModule(moduleName, callback) {\n if (typeof require === 'undefined') {\n import(moduleName)\n .then((mod) => {\n callback(null, mod?.default ?? null);\n })\n .catch(callback);\n } else {\n try {\n callback(null, require(moduleName));\n } catch (err) {\n callback(err, null);\n }\n }\n}\n\nexport default function loadNodeVersionInstall(callback: (err: Error | null, installVersion: InstallVersionFn) => void): void {\n if (cached !== undefined) return callback(null, cached);\n\n installModule(moduleName, nodeModules, {}, (err) => {\n if (err) return callback(err, null);\n loadModule(moduleName, (err, _cached: InstallVersionFn) => {\n if (err) return callback(err, null);\n cached = _cached;\n callback(null, cached);\n });\n });\n}\n"],"names":["installModule","path","url","_dirname","dirname","__filename","fileURLToPath","nodeModules","join","moduleName","cached","loadModule","callback","require","then","mod","default","catch","err","loadNodeVersionInstall","undefined","_cached"],"mappings":"AAAA,OAAOA,mBAAmB,wBAAwB;AAElD,OAAOC,UAAU,OAAO;AACxB,OAAOC,SAAS,MAAM;AAEtB,MAAMC,WAAWF,KAAKG,OAAO,CAAC,OAAOC,eAAe,cAAcH,IAAII,aAAa,CAAC,YAAYJ,GAAG,IAAIG;AACvG,MAAME,cAAcN,KAAKO,IAAI,CAACL,UAAU,MAAM,MAAM,MAAM;AAC1D,MAAMM,aAAa;AAKnB,IAAIC;AAEJ,SAASC,WAAWF,UAAU,EAAEG,QAAQ;IACtC,IAAI,OAAOC,YAAY,aAAa;QAClC,MAAM,CAACJ,YACJK,IAAI,CAAC,CAACC;;YACLH,SAAS,cAAMG,gBAAAA,0BAAAA,IAAKC,OAAO,uCAAI;QACjC,GACCC,KAAK,CAACL;IACX,OAAO;QACL,IAAI;YACFA,SAAS,MAAMC,QAAQJ;QACzB,EAAE,OAAOS,KAAK;YACZN,SAASM,KAAK;QAChB;IACF;AACF;AAEA,eAAe,SAASC,uBAAuBP,QAAuE;IACpH,IAAIF,WAAWU,WAAW,OAAOR,SAAS,MAAMF;IAEhDV,cAAcS,YAAYF,aAAa,CAAC,GAAG,CAACW;QAC1C,IAAIA,KAAK,OAAON,SAASM,KAAK;QAC9BP,WAAWF,YAAY,CAACS,KAAKG;YAC3B,IAAIH,KAAK,OAAON,SAASM,KAAK;YAC9BR,SAASW;YACTT,SAAS,MAAMF;QACjB;IACF;AACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Find a system binary by searching PATH, excluding ~/.nvu/bin
|
|
3
|
+
* Returns the full path to the binary, or null if not found
|
|
4
|
+
*/
|
|
5
|
+
export declare function resolveSystemBinary(name: string): string | null;
|
|
6
|
+
/**
|
|
7
|
+
* Get PATH with ~/.nvu/bin removed
|
|
8
|
+
* Used to create an environment for spawning system commands
|
|
9
|
+
*/
|
|
10
|
+
export declare function getPathWithoutNvuBin(): string;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve system binaries by searching PATH while excluding ~/.nvu/bin
|
|
3
|
+
* This mirrors the Go binary's findSystemBinary() function
|
|
4
|
+
*/ import fs from 'fs';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
import { homedir } from '../compat.js';
|
|
7
|
+
const isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE);
|
|
8
|
+
const nvuBinDir = path.join(homedir(), '.nvu', 'bin');
|
|
9
|
+
/**
|
|
10
|
+
* Check if two paths are equal (case-insensitive on Windows)
|
|
11
|
+
*/ function pathsEqual(a, b) {
|
|
12
|
+
if (isWindows) {
|
|
13
|
+
return a.toLowerCase() === b.toLowerCase();
|
|
14
|
+
}
|
|
15
|
+
return a === b;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Check if a path is within the nvu bin directory
|
|
19
|
+
*/ function isInNvuBin(filePath) {
|
|
20
|
+
try {
|
|
21
|
+
const realPath = fs.realpathSync(filePath);
|
|
22
|
+
return realPath.indexOf(path.join('.nvu', 'bin')) >= 0 || pathsEqual(path.dirname(realPath), nvuBinDir);
|
|
23
|
+
} catch (_e) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Find a system binary by searching PATH, excluding ~/.nvu/bin
|
|
29
|
+
* Returns the full path to the binary, or null if not found
|
|
30
|
+
*/ export function resolveSystemBinary(name) {
|
|
31
|
+
const pathEnv = process.env.PATH || '';
|
|
32
|
+
const pathSep = isWindows ? ';' : ':';
|
|
33
|
+
const dirs = pathEnv.split(pathSep);
|
|
34
|
+
for(let i = 0; i < dirs.length; i++){
|
|
35
|
+
const dir = dirs[i];
|
|
36
|
+
if (!dir) continue;
|
|
37
|
+
// Skip ~/.nvu/bin
|
|
38
|
+
if (pathsEqual(dir, nvuBinDir)) continue;
|
|
39
|
+
// Build candidate path with appropriate extension
|
|
40
|
+
const candidates = isWindows ? [
|
|
41
|
+
path.join(dir, `${name}.exe`),
|
|
42
|
+
path.join(dir, `${name}.cmd`),
|
|
43
|
+
path.join(dir, name)
|
|
44
|
+
] : [
|
|
45
|
+
path.join(dir, name)
|
|
46
|
+
];
|
|
47
|
+
for(let j = 0; j < candidates.length; j++){
|
|
48
|
+
const candidate = candidates[j];
|
|
49
|
+
try {
|
|
50
|
+
const stat = fs.statSync(candidate);
|
|
51
|
+
if (!stat.isFile()) continue;
|
|
52
|
+
// Make sure it's not in ~/.nvu/bin (via symlink)
|
|
53
|
+
if (isInNvuBin(candidate)) continue;
|
|
54
|
+
return candidate;
|
|
55
|
+
} catch (_e) {
|
|
56
|
+
// File doesn't exist, continue
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Get PATH with ~/.nvu/bin removed
|
|
64
|
+
* Used to create an environment for spawning system commands
|
|
65
|
+
*/ export function getPathWithoutNvuBin() {
|
|
66
|
+
const pathEnv = process.env.PATH || '';
|
|
67
|
+
const pathSep = isWindows ? ';' : ':';
|
|
68
|
+
const dirs = pathEnv.split(pathSep);
|
|
69
|
+
const filtered = [];
|
|
70
|
+
for(let i = 0; i < dirs.length; i++){
|
|
71
|
+
const dir = dirs[i];
|
|
72
|
+
if (!dir) continue;
|
|
73
|
+
if (pathsEqual(dir, nvuBinDir)) continue;
|
|
74
|
+
if (dir.indexOf(path.join('.nvu', 'bin')) >= 0) continue;
|
|
75
|
+
filtered.push(dir);
|
|
76
|
+
}
|
|
77
|
+
return filtered.join(pathSep);
|
|
78
|
+
}
|
|
@@ -0,0 +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 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');\n\n/**\n * Check if two paths are equal (case-insensitive on Windows)\n */\nfunction pathsEqual(a: string, b: string): boolean {\n if (isWindows) {\n return a.toLowerCase() === b.toLowerCase();\n }\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.PATH || '';\n const pathSep = isWindows ? ';' : ':';\n const dirs = pathEnv.split(pathSep);\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.PATH || '';\n const pathSep = isWindows ? ';' : ':';\n const dirs = pathEnv.split(pathSep);\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(pathSep);\n}\n"],"names":["fs","path","homedir","isWindows","process","platform","test","env","OSTYPE","nvuBinDir","join","pathsEqual","a","b","toLowerCase","isInNvuBin","filePath","realPath","realpathSync","indexOf","dirname","_e","resolveSystemBinary","name","pathEnv","PATH","pathSep","dirs","split","i","length","dir","candidates","j","candidate","stat","statSync","isFile","getPathWithoutNvuBin","filtered","push"],"mappings":"AAAA;;;CAGC,GACD,OAAOA,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;AAE/C;;CAEC,GACD,SAASS,WAAWC,CAAS,EAAEC,CAAS;IACtC,IAAIV,WAAW;QACb,OAAOS,EAAEE,WAAW,OAAOD,EAAEC,WAAW;IAC1C;IACA,OAAOF,MAAMC;AACf;AAEA;;CAEC,GACD,SAASE,WAAWC,QAAgB;IAClC,IAAI;QACF,MAAMC,WAAWjB,GAAGkB,YAAY,CAACF;QACjC,OAAOC,SAASE,OAAO,CAAClB,KAAKS,IAAI,CAAC,QAAQ,WAAW,KAAKC,WAAWV,KAAKmB,OAAO,CAACH,WAAWR;IAC/F,EAAE,OAAOY,IAAI;QACX,OAAO;IACT;AACF;AAEA;;;CAGC,GACD,OAAO,SAASC,oBAAoBC,IAAY;IAC9C,MAAMC,UAAUpB,QAAQG,GAAG,CAACkB,IAAI,IAAI;IACpC,MAAMC,UAAUvB,YAAY,MAAM;IAClC,MAAMwB,OAAOH,QAAQI,KAAK,CAACF;IAE3B,IAAK,IAAIG,IAAI,G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ACvB"}
|
package/dist/esm/worker.js
CHANGED
|
@@ -7,9 +7,10 @@ import Queue from 'queue-cb';
|
|
|
7
7
|
import resolveBin from 'resolve-bin-sync';
|
|
8
8
|
import spawnStreaming from 'spawn-streaming';
|
|
9
9
|
import { createSession, formatArguments } from 'spawn-term';
|
|
10
|
-
import { stringEndsWith } from './compat.js';
|
|
10
|
+
import { objectAssign, stringEndsWith } from './compat.js';
|
|
11
11
|
import { storagePath } from './constants.js';
|
|
12
12
|
import loadNodeVersionInstall from './lib/loadNodeVersionInstall.js';
|
|
13
|
+
import { getPathWithoutNvuBin, resolveSystemBinary } from './lib/resolveSystemBinary.js';
|
|
13
14
|
const isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE);
|
|
14
15
|
const NODE = isWindows ? 'node.exe' : 'node';
|
|
15
16
|
// Parse npm-generated .cmd wrapper to extract the JS script path
|
|
@@ -43,9 +44,8 @@ function resolveCommand(command, args) {
|
|
|
43
44
|
return {
|
|
44
45
|
command: NODE,
|
|
45
46
|
args: [
|
|
46
|
-
scriptPath
|
|
47
|
-
|
|
48
|
-
]
|
|
47
|
+
scriptPath
|
|
48
|
+
].concat(args)
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
}
|
|
@@ -55,9 +55,8 @@ function resolveCommand(command, args) {
|
|
|
55
55
|
return {
|
|
56
56
|
command: NODE,
|
|
57
57
|
args: [
|
|
58
|
-
binPath
|
|
59
|
-
|
|
60
|
-
]
|
|
58
|
+
binPath
|
|
59
|
+
].concat(args)
|
|
61
60
|
};
|
|
62
61
|
} catch (_e) {
|
|
63
62
|
// Not an npm package bin, use original command
|
|
@@ -68,6 +67,11 @@ function resolveCommand(command, args) {
|
|
|
68
67
|
};
|
|
69
68
|
}
|
|
70
69
|
export default function worker(versionExpression, command, args, options, callback) {
|
|
70
|
+
// Handle "system" as a special version that uses system binaries directly
|
|
71
|
+
if (versionExpression === 'system') {
|
|
72
|
+
runWithSystemBinaries(command, args, options, callback);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
71
75
|
// Load node-version-install lazily
|
|
72
76
|
loadNodeVersionInstall((loadErr, installVersion)=>{
|
|
73
77
|
if (loadErr) return callback(loadErr);
|
|
@@ -77,10 +81,9 @@ export default function worker(versionExpression, command, args, options, callba
|
|
|
77
81
|
callback(new Error(`No versions found from expression: ${versionExpression}`));
|
|
78
82
|
return;
|
|
79
83
|
}
|
|
80
|
-
const installOptions = {
|
|
81
|
-
storagePath
|
|
82
|
-
|
|
83
|
-
};
|
|
84
|
+
const installOptions = objectAssign({
|
|
85
|
+
storagePath: storagePath
|
|
86
|
+
}, options);
|
|
84
87
|
const streamingOptions = options;
|
|
85
88
|
const results = [];
|
|
86
89
|
const queue = new Queue(1);
|
|
@@ -153,3 +156,47 @@ export default function worker(versionExpression, command, args, options, callba
|
|
|
153
156
|
});
|
|
154
157
|
});
|
|
155
158
|
}
|
|
159
|
+
/**
|
|
160
|
+
* Run command using system binaries (bypassing nvu version management)
|
|
161
|
+
* This handles the "system" version specifier
|
|
162
|
+
*/ function runWithSystemBinaries(command, args, options, callback) {
|
|
163
|
+
// Find the system binary for the command
|
|
164
|
+
const systemBinary = resolveSystemBinary(command);
|
|
165
|
+
if (!systemBinary) {
|
|
166
|
+
callback(new Error(`System ${command} not found in PATH`));
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
// Create spawn options with PATH excluding ~/.nvu/bin
|
|
170
|
+
// This ensures any child processes also use system binaries
|
|
171
|
+
const cleanPath = getPathWithoutNvuBin();
|
|
172
|
+
const spawnOptions = objectAssign({}, options);
|
|
173
|
+
spawnOptions.env = objectAssign({}, process.env);
|
|
174
|
+
spawnOptions.env.PATH = cleanPath;
|
|
175
|
+
spawnOptions.stdio = options.stdio || 'inherit';
|
|
176
|
+
// On Windows, resolve npm bin commands to bypass .cmd wrappers
|
|
177
|
+
const resolved = resolveCommand(command, args);
|
|
178
|
+
// For system, use the resolved system binary path
|
|
179
|
+
const finalCommand = resolved.command === command ? systemBinary : resolved.command;
|
|
180
|
+
const finalArgs = resolved.command === command ? args : resolved.args;
|
|
181
|
+
if (!options.silent) {
|
|
182
|
+
console.log(`$ ${formatArguments([
|
|
183
|
+
finalCommand
|
|
184
|
+
].concat(finalArgs)).join(' ')}`);
|
|
185
|
+
}
|
|
186
|
+
spawn(finalCommand, finalArgs, spawnOptions, (err, res)=>{
|
|
187
|
+
if (err && err.message && err.message.indexOf('ExperimentalWarning') >= 0) {
|
|
188
|
+
res = err;
|
|
189
|
+
err = null;
|
|
190
|
+
}
|
|
191
|
+
const result = {
|
|
192
|
+
install: null,
|
|
193
|
+
command,
|
|
194
|
+
version: 'system',
|
|
195
|
+
error: err,
|
|
196
|
+
result: res
|
|
197
|
+
};
|
|
198
|
+
callback(err, [
|
|
199
|
+
result
|
|
200
|
+
]);
|
|
201
|
+
});
|
|
202
|
+
}
|
package/dist/esm/worker.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/worker.ts"],"sourcesContent":["import spawn, { type SpawnOptions } from 'cross-spawn-cb';\nimport fs from 'fs';\nimport resolveVersions, { type VersionOptions } from 'node-resolve-versions';\nimport type { InstallOptions } from 'node-version-install';\nimport { spawnOptions as createSpawnOptions } from 'node-version-utils';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport resolveBin from 'resolve-bin-sync';\nimport spawnStreaming from 'spawn-streaming';\nimport { createSession, formatArguments } from 'spawn-term';\nimport { stringEndsWith } from './compat.ts';\nimport { storagePath } from './constants.ts';\nimport loadNodeVersionInstall from './lib/loadNodeVersionInstall.ts';\n\nimport type { Options, UseCallback, UseOptions, UseResult } from './types.ts';\n\nconst isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE);\nconst NODE = isWindows ? 'node.exe' : 'node';\n\n// Parse npm-generated .cmd wrapper to extract the JS script path\nfunction parseNpmCmdWrapper(cmdPath: string): string | null {\n try {\n const content = fs.readFileSync(cmdPath, 'utf8');\n // Match: \"%_prog%\" \"%dp0%\\node_modules\\...\\cli.js\" %*\n // or: \"%_prog%\" \"%dp0%\\path\\to\\script.js\" %*\n const match = content.match(/\"%_prog%\"\\s+\"?%dp0%\\\\([^\"]+)\"?\\s+%\\*/);\n if (match) {\n const relativePath = match[1];\n const cmdDir = path.dirname(cmdPath);\n return path.join(cmdDir, relativePath);\n }\n } catch (_e) {\n // ignore\n }\n return null;\n}\n\n// On Windows, resolve npm bin commands to their JS entry points to bypass .cmd wrappers\n// This fixes issues with nvm-windows where .cmd wrappers use symlinked node.exe directly\nfunction resolveCommand(command: string, args: string[]): { command: string; args: string[] } {\n if (!isWindows) return { command, args };\n\n // Case 1: Command is a .cmd file path\n if (stringEndsWith(command.toLowerCase(), '.cmd')) {\n const scriptPath = parseNpmCmdWrapper(command);\n if (scriptPath) {\n return { command: NODE, args: [scriptPath, ...args] };\n }\n }\n\n // Case 2: Try to resolve the command as an npm package bin from node_modules\n try {\n const binPath = resolveBin(command);\n return { command: NODE, args: [binPath, ...args] };\n } catch (_e) {\n // Not an npm package bin, use original command\n }\n\n return { command, args };\n}\n\nexport default function worker(versionExpression: string, command: string, args: string[], options: UseOptions, callback: UseCallback): void {\n // Load node-version-install lazily\n loadNodeVersionInstall((loadErr, installVersion) => {\n if (loadErr) return callback(loadErr);\n\n resolveVersions(versionExpression, options as VersionOptions, (err?: Error, versions?: string[]) => {\n if (err) return callback(err);\n if (!versions.length) {\n callback(new Error(`No versions found from expression: ${versionExpression}`));\n return;\n }\n\n const installOptions = { storagePath, ...options } as InstallOptions;\n const streamingOptions = options as Options;\n const results: UseResult[] = [];\n const queue = new Queue(1);\n\n // Create session once for all processes (only if multiple versions)\n const interactive = options.interactive !== false;\n const session = versions.length >= 2 && createSession && !streamingOptions.streaming ? createSession({ header: `${command} ${args.join(' ')}`, showStatusBar: true, interactive }) : null;\n\n versions.forEach((version: string) => {\n queue.defer((cb) => {\n installVersion(version, installOptions, (err, installs) => {\n const install = installs && installs.length === 1 ? installs[0] : null;\n if (err || !install) {\n const error = err || new Error(`Unexpected version results for version ${version}. Install ${JSON.stringify(installs)}`);\n results.push({ install, command, version, error, result: null });\n return cb();\n }\n const spawnOptions = createSpawnOptions(install.installPath, options as SpawnOptions);\n const prefix = install.version;\n\n function next(err?, res?): void {\n if (err && err.message.indexOf('ExperimentalWarning') >= 0) {\n res = err;\n err = null;\n }\n results.push({ install, command, version, error: err, result: res });\n cb();\n }\n\n // On Windows, resolve npm bin commands to bypass .cmd wrappers\n const resolved = resolveCommand(command, args);\n\n if (versions.length < 2) {\n // Show command when running single version (no terminal session, unless silent)\n if (!options.silent) console.log(`$ ${formatArguments([resolved.command].concat(resolved.args)).join(' ')}`);\n return spawn(resolved.command, resolved.args, spawnOptions, next);\n }\n if (session) session.spawn(resolved.command, resolved.args, spawnOptions, { group: prefix, expanded: streamingOptions.expanded }, next);\n else spawnStreaming(resolved.command, resolved.args, spawnOptions, { prefix }, next);\n });\n });\n });\n queue.await((err) => {\n if (session) {\n session.waitAndClose(() => {\n err ? callback(err) : callback(null, results);\n });\n } else {\n err ? callback(err) : callback(null, results);\n }\n });\n });\n });\n}\n"],"names":["spawn","fs","resolveVersions","spawnOptions","createSpawnOptions","path","Queue","resolveBin","spawnStreaming","createSession","formatArguments","stringEndsWith","storagePath","loadNodeVersionInstall","isWindows","process","platform","test","env","OSTYPE","NODE","parseNpmCmdWrapper","cmdPath","content","readFileSync","match","relativePath","cmdDir","dirname","join","_e","resolveCommand","command","args","toLowerCase","scriptPath","binPath","worker","versionExpression","options","callback","loadErr","installVersion","err","versions","length","Error","installOptions","streamingOptions","results","queue","interactive","session","streaming","header","showStatusBar","forEach","version","defer","cb","installs","install","error","JSON","stringify","push","result","installPath","prefix","next","res","message","indexOf","resolved","silent","console","log","concat","group","expanded","await","waitAndClose"],"mappings":"AAAA,OAAOA,WAAkC,iBAAiB;AAC1D,OAAOC,QAAQ,KAAK;AACpB,OA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MAAMH,SAASG,OAAOH,SAAS,MAAMS;gBACvC;YACF;QACF;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/worker.ts"],"sourcesContent":["import spawn, { type SpawnOptions } from 'cross-spawn-cb';\nimport fs from 'fs';\nimport resolveVersions, { type VersionOptions } from 'node-resolve-versions';\nimport type { InstallOptions } from 'node-version-install';\nimport { spawnOptions as createSpawnOptions } from 'node-version-utils';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport resolveBin from 'resolve-bin-sync';\nimport spawnStreaming from 'spawn-streaming';\nimport { createSession, formatArguments } from 'spawn-term';\nimport { objectAssign, stringEndsWith } from './compat.ts';\nimport { storagePath } from './constants.ts';\nimport loadNodeVersionInstall from './lib/loadNodeVersionInstall.ts';\nimport { getPathWithoutNvuBin, resolveSystemBinary } from './lib/resolveSystemBinary.ts';\n\nimport type { Options, UseCallback, UseOptions, UseResult } from './types.ts';\n\nconst isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE);\nconst NODE = isWindows ? 'node.exe' : 'node';\n\n// Parse npm-generated .cmd wrapper to extract the JS script path\nfunction parseNpmCmdWrapper(cmdPath: string): string | null {\n try {\n const content = fs.readFileSync(cmdPath, 'utf8');\n // Match: \"%_prog%\" \"%dp0%\\node_modules\\...\\cli.js\" %*\n // or: \"%_prog%\" \"%dp0%\\path\\to\\script.js\" %*\n const match = content.match(/\"%_prog%\"\\s+\"?%dp0%\\\\([^\"]+)\"?\\s+%\\*/);\n if (match) {\n const relativePath = match[1];\n const cmdDir = path.dirname(cmdPath);\n return path.join(cmdDir, relativePath);\n }\n } catch (_e) {\n // ignore\n }\n return null;\n}\n\n// On Windows, resolve npm bin commands to their JS entry points to bypass .cmd wrappers\n// This fixes issues with nvm-windows where .cmd wrappers use symlinked node.exe directly\nfunction resolveCommand(command: string, args: string[]): { command: string; args: string[] } {\n if (!isWindows) return { command, args };\n\n // Case 1: Command is a .cmd file path\n if (stringEndsWith(command.toLowerCase(), '.cmd')) {\n const scriptPath = parseNpmCmdWrapper(command);\n if (scriptPath) {\n return { command: NODE, args: [scriptPath].concat(args) };\n }\n }\n\n // Case 2: Try to resolve the command as an npm package bin from node_modules\n try {\n const binPath = resolveBin(command);\n return { command: NODE, args: [binPath].concat(args) };\n } catch (_e) {\n // Not an npm package bin, use original command\n }\n\n return { command, args };\n}\n\nexport default function worker(versionExpression: string, command: string, args: string[], options: UseOptions, callback: UseCallback): void {\n // Handle \"system\" as a special version that uses system binaries directly\n if (versionExpression === 'system') {\n runWithSystemBinaries(command, args, options, callback);\n return;\n }\n\n // Load node-version-install lazily\n loadNodeVersionInstall((loadErr, installVersion) => {\n if (loadErr) return callback(loadErr);\n\n resolveVersions(versionExpression, options as VersionOptions, (err?: Error, versions?: string[]) => {\n if (err) return callback(err);\n if (!versions.length) {\n callback(new Error(`No versions found from expression: ${versionExpression}`));\n return;\n }\n\n const installOptions = objectAssign({ storagePath: storagePath }, options) as InstallOptions;\n const streamingOptions = options as Options;\n const results: UseResult[] = [];\n const queue = new Queue(1);\n\n // Create session once for all processes (only if multiple versions)\n const interactive = options.interactive !== false;\n const session = versions.length >= 2 && createSession && !streamingOptions.streaming ? createSession({ header: `${command} ${args.join(' ')}`, showStatusBar: true, interactive }) : null;\n\n versions.forEach((version: string) => {\n queue.defer((cb) => {\n installVersion(version, installOptions, (err, installs) => {\n const install = installs && installs.length === 1 ? installs[0] : null;\n if (err || !install) {\n const error = err || new Error(`Unexpected version results for version ${version}. Install ${JSON.stringify(installs)}`);\n results.push({ install, command, version, error, result: null });\n return cb();\n }\n const spawnOptions = createSpawnOptions(install.installPath, options as SpawnOptions);\n const prefix = install.version;\n\n function next(err?, res?): void {\n if (err && err.message.indexOf('ExperimentalWarning') >= 0) {\n res = err;\n err = null;\n }\n results.push({ install, command, version, error: err, result: res });\n cb();\n }\n\n // On Windows, resolve npm bin commands to bypass .cmd wrappers\n const resolved = resolveCommand(command, args);\n\n if (versions.length < 2) {\n // Show command when running single version (no terminal session, unless silent)\n if (!options.silent) console.log(`$ ${formatArguments([resolved.command].concat(resolved.args)).join(' ')}`);\n return spawn(resolved.command, resolved.args, spawnOptions, next);\n }\n if (session) session.spawn(resolved.command, resolved.args, spawnOptions, { group: prefix, expanded: streamingOptions.expanded }, next);\n else spawnStreaming(resolved.command, resolved.args, spawnOptions, { prefix }, next);\n });\n });\n });\n queue.await((err) => {\n if (session) {\n session.waitAndClose(() => {\n err ? callback(err) : callback(null, results);\n });\n } else {\n err ? callback(err) : callback(null, results);\n }\n });\n });\n });\n}\n\n/**\n * Run command using system binaries (bypassing nvu version management)\n * This handles the \"system\" version specifier\n */\nfunction runWithSystemBinaries(command: string, args: string[], options: UseOptions, callback: UseCallback): void {\n // Find the system binary for the command\n const systemBinary = resolveSystemBinary(command);\n if (!systemBinary) {\n callback(new Error(`System ${command} not found in PATH`));\n return;\n }\n\n // Create spawn options with PATH excluding ~/.nvu/bin\n // This ensures any child processes also use system binaries\n const cleanPath = getPathWithoutNvuBin();\n const spawnOptions: SpawnOptions = objectAssign({}, options as SpawnOptions);\n spawnOptions.env = objectAssign({}, process.env);\n spawnOptions.env.PATH = cleanPath;\n spawnOptions.stdio = options.stdio || 'inherit';\n\n // On Windows, resolve npm bin commands to bypass .cmd wrappers\n const resolved = resolveCommand(command, args);\n\n // For system, use the resolved system binary path\n const finalCommand = resolved.command === command ? systemBinary : resolved.command;\n const finalArgs = resolved.command === command ? args : resolved.args;\n\n if (!options.silent) {\n console.log(`$ ${formatArguments([finalCommand].concat(finalArgs)).join(' ')}`);\n }\n\n spawn(finalCommand, finalArgs, spawnOptions, (err?, res?) => {\n if (err && err.message && err.message.indexOf('ExperimentalWarning') >= 0) {\n res = err;\n err = null;\n }\n\n const result: UseResult = {\n install: null,\n command,\n version: 'system',\n error: err,\n result: res,\n };\n\n callback(err, [result]);\n });\n}\n"],"names":["spawn","fs","resolveVersions","spawnOptions","createSpawnOptions","path","Queue","resolveBin","spawnStreaming","createSession","formatArguments","objectAssign","stringEndsWith","storagePath","loadNodeVersionInstall","getPathWithoutNvuBin","resolveSystemBinary","isWindows","process","platform","test","env","OSTYPE","NODE","parseNpmCmdWrapper","cmdPath","content","readFileSync","match","relativePath","cmdDir","dirname","join","_e","resolveCommand","command","args","toLowerCase","scriptPath","concat","binPath","worker","versionExpression","options","callback","runWithSystemBinaries","loadErr","installVersion","err","versions","length","Error","installOptions","streamingOptions","results","queue","interactive","session","streaming","header","showStatusBar","forEach","version","defer","cb","installs","install","error","JSON","stringify","push","result","installPath","prefix","next","res","message","indexOf","resolved","silent","console","log","group","expanded","await","waitAndClose","systemBinary","cleanPath","PATH","stdio","finalCommand","finalArgs"],"mappings":"AAAA,OAAOA,WAAkC,iBAAiB;AAC1D,OAAOC,QAAQ,KAAK;AACpB,OAAOC,qBAA8C,wBAAwB;AAE7E,SAASC,gBAAgBC,kBAAkB,QAAQ,qBAAqB;AACxE,OAAOC,UAAU,OAAO;AACxB,OAAOC,WAAW,WAAW;AAC7B,OAAOC,gBAAgB,mBAAmB;AAC1C,OAAOC,oBAAoB,kBAAkB;AAC7C,SAASC,aAAa,EAAEC,eAAe,QAAQ,aAAa;AAC5D,SAASC,YAAY,EAAEC,cAAc,QAAQ,cAAc;AAC3D,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,OAAOC,4BAA4B,kCAAkC;AACrE,SAASC,oBAAoB,EAAEC,mBAAmB,QAAQ,+BAA+B;AAIzF,MAAMC,YAAYC,QAAQC,QAAQ,KAAK,WAAW,kBAAkBC,IAAI,CAACF,QAAQG,GAAG,CAACC,MAAM;AAC3F,MAAMC,OAAON,YAAY,aAAa;AAEtC,iEAAiE;AACjE,SAASO,mBAAmBC,OAAe;IACzC,IAAI;QACF,MAAMC,UAAUzB,GAAG0B,YAAY,CAACF,SAAS;QACzC,uDAAuD;QACvD,8CAA8C;QAC9C,MAAMG,QAAQF,QAAQE,KAAK,CAAC;QAC5B,IAAIA,OAAO;YACT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K,GAAG9C,QAAQ8C,KAAK,IAAI;IAEtC,+DAA+D;IAC/D,MAAMX,WAAW5C,eAAeC,SAASC;IAEzC,kDAAkD;IAClD,MAAMsD,eAAeZ,SAAS3C,OAAO,KAAKA,UAAUmD,eAAeR,SAAS3C,OAAO;IACnF,MAAMwD,YAAYb,SAAS3C,OAAO,KAAKA,UAAUC,OAAO0C,SAAS1C,IAAI;IAErE,IAAI,CAACO,QAAQoC,MAAM,EAAE;QACnBC,QAAQC,GAAG,CAAC,CAAC,EAAE,EAAEvE,gBAAgB;YAACgF;SAAa,CAACnD,MAAM,CAACoD,YAAY3D,IAAI,CAAC,MAAM;IAChF;IAEAhC,MAAM0F,cAAcC,WAAWxF,cAAc,CAAC6C,KAAM2B;QAClD,IAAI3B,OAAOA,IAAI4B,OAAO,IAAI5B,IAAI4B,OAAO,CAACC,OAAO,CAAC,0BAA0B,GAAG;YACzEF,MAAM3B;YACNA,MAAM;QACR;QAEA,MAAMuB,SAAoB;YACxBL,SAAS;YACT/B;YACA2B,SAAS;YACTK,OAAOnB;YACPuB,QAAQI;QACV;QAEA/B,SAASI,KAAK;YAACuB;SAAO;IACxB;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-version-use",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.2",
|
|
4
4
|
"description": "Cross-platform solution for using multiple versions of node. Useful for compatibility testing",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node",
|
|
@@ -49,7 +49,6 @@
|
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"cross-spawn-cb": "^3.0.0",
|
|
52
|
-
"env-path-key": "^1.0.0",
|
|
53
52
|
"exit-compat": "^1.0.0",
|
|
54
53
|
"fs-remove-compat": "^1.0.0",
|
|
55
54
|
"get-file-compat": "^2.0.0",
|
|
@@ -72,6 +71,7 @@
|
|
|
72
71
|
"@types/mocha": "*",
|
|
73
72
|
"@types/node": "*",
|
|
74
73
|
"cr": "^0.1.0",
|
|
74
|
+
"env-path-key": "^1.1.8",
|
|
75
75
|
"fs-copy-compat": "^1.0.0",
|
|
76
76
|
"fs-remove-compat": "^1.0.0",
|
|
77
77
|
"is-version": "^1.0.9",
|