node-version-use 2.1.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/cjs/cli.js +7 -7
  2. package/dist/cjs/cli.js.map +1 -1
  3. package/dist/cjs/commands/default.js +4 -4
  4. package/dist/cjs/commands/default.js.map +1 -1
  5. package/dist/cjs/commands/install.js +6 -6
  6. package/dist/cjs/commands/install.js.map +1 -1
  7. package/dist/cjs/commands/list.js +4 -4
  8. package/dist/cjs/commands/list.js.map +1 -1
  9. package/dist/cjs/commands/local.js +6 -6
  10. package/dist/cjs/commands/local.js.map +1 -1
  11. package/dist/cjs/commands/setup.js +2 -2
  12. package/dist/cjs/commands/setup.js.map +1 -1
  13. package/dist/cjs/commands/teardown.js +2 -2
  14. package/dist/cjs/commands/teardown.js.map +1 -1
  15. package/dist/cjs/commands/uninstall.js +6 -6
  16. package/dist/cjs/commands/uninstall.js.map +1 -1
  17. package/dist/cjs/commands/which.js +3 -3
  18. package/dist/cjs/commands/which.js.map +1 -1
  19. package/dist/esm/cli.js +1 -1
  20. package/dist/esm/cli.js.map +1 -1
  21. package/dist/esm/commands/default.js +1 -1
  22. package/dist/esm/commands/default.js.map +1 -1
  23. package/dist/esm/commands/install.js +1 -1
  24. package/dist/esm/commands/install.js.map +1 -1
  25. package/dist/esm/commands/list.js +1 -1
  26. package/dist/esm/commands/list.js.map +1 -1
  27. package/dist/esm/commands/local.js +1 -1
  28. package/dist/esm/commands/local.js.map +1 -1
  29. package/dist/esm/commands/setup.js +1 -1
  30. package/dist/esm/commands/setup.js.map +1 -1
  31. package/dist/esm/commands/teardown.js +1 -1
  32. package/dist/esm/commands/teardown.js.map +1 -1
  33. package/dist/esm/commands/uninstall.js +1 -1
  34. package/dist/esm/commands/uninstall.js.map +1 -1
  35. package/dist/esm/commands/which.js +1 -1
  36. package/dist/esm/commands/which.js.map +1 -1
  37. package/package.json +4 -4
  38. package/scripts/postinstall.cjs +1 -1
package/dist/cjs/cli.js CHANGED
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "default", {
8
8
  return _default;
9
9
  }
10
10
  });
11
- var _exit = /*#__PURE__*/ _interop_require_default(require("exit"));
11
+ var _exitcompat = /*#__PURE__*/ _interop_require_default(require("exit-compat"));
12
12
  var _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
13
13
  var _getoptscompat = /*#__PURE__*/ _interop_require_default(require("getopts-compat"));
14
14
  var _path = /*#__PURE__*/ _interop_require_default(require("path"));
@@ -92,12 +92,12 @@ var _default = function(argv, name) {
92
92
  });
93
93
  if (options.version) {
94
94
  console.log(getVersion());
95
- (0, _exit.default)(0);
95
+ (0, _exitcompat.default)(0);
96
96
  return;
97
97
  }
98
98
  if (options.help) {
99
99
  printHelp(name);
100
- (0, _exit.default)(0);
100
+ (0, _exitcompat.default)(0);
101
101
  return;
102
102
  }
103
103
  // Check if first argument is a subcommand
@@ -111,19 +111,19 @@ var _default = function(argv, name) {
111
111
  options.sort = options.desc ? -1 : 1;
112
112
  if (args.length === 0) {
113
113
  console.log("Missing version expression. Example usage: ".concat(name, " version command arg1 arg2"));
114
- (0, _exit.default)(ERROR_CODE);
114
+ (0, _exitcompat.default)(ERROR_CODE);
115
115
  return;
116
116
  }
117
117
  if (args.length === 1) {
118
118
  console.log("Missing command. Example usage: ".concat(name, " version command arg1 arg2"));
119
- (0, _exit.default)(ERROR_CODE);
119
+ (0, _exitcompat.default)(ERROR_CODE);
120
120
  return;
121
121
  }
122
122
  options.stdio = 'inherit'; // pass through stdio
123
123
  (0, _indexts1.default)(args[0], args[1], args.slice(2), options, function(err, results) {
124
124
  if (err && !err.results) {
125
125
  console.log(err.message);
126
- (0, _exit.default)(ERROR_CODE);
126
+ (0, _exitcompat.default)(ERROR_CODE);
127
127
  return;
128
128
  }
129
129
  if (err) results = err.results;
@@ -142,7 +142,7 @@ var _default = function(argv, name) {
142
142
  if (errors.length) console.log("".concat(_spawnterm.figures.cross, " ").concat(errors.length, " failed"));
143
143
  }
144
144
  }
145
- (0, _exit.default)(err || errors.length ? ERROR_CODE : 0);
145
+ (0, _exitcompat.default)(err || errors.length ? ERROR_CODE : 0);
146
146
  });
147
147
  };
148
148
  /* 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; }
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/cli.ts"],"sourcesContent":["import exit from 'exit';\nimport fs from 'fs';\nimport getopts from 'getopts-compat';\nimport path from 'path';\nimport { createSession, figures, formatArguments } from 'spawn-term';\nimport url from 'url';\nimport { isCommand, runCommand } from './commands/index.ts';\nimport run from './index.ts';\nimport type { UseError, UseOptions, UseResult } from './types.ts';\n\nconst __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url));\n\nconst ERROR_CODE = 13;\n\nfunction getVersion(): string {\n const packagePath = path.join(__dirname, '..', '..', 'package.json');\n const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf8'));\n return packageJson.version;\n}\n\nfunction printHelp(name: string): void {\n const version = getVersion();\n console.log(`${name} v${version}`);\n console.log('');\n console.log(`Usage: ${name} [options] <version> <command> [args...]`);\n console.log(` ${name} <subcommand> [args...]`);\n console.log('');\n console.log('Run commands with specific Node.js versions');\n console.log('');\n console.log('Subcommands:');\n console.log(' default [version] Set or display the global default Node version');\n console.log(' local [version] Set or display the local Node version (.nvmrc)');\n console.log(' install <version> Download and install a Node version');\n console.log(' uninstall <version> Remove an installed Node version');\n console.log(' list List installed Node versions');\n console.log(' which Show which Node version would be used');\n console.log(' setup Install/reinstall binaries to ~/.nvu/bin');\n console.log(' teardown Remove binaries from ~/.nvu/bin');\n console.log('');\n console.log('Options:');\n console.log(' -v, --version Print version number');\n console.log(' -h, --help Print this help message');\n console.log(' -r, --range Range type (major, minor, patch) with filters (lts, even, odd)');\n console.log(' Default: major,even');\n console.log(' -d, --desc Sort versions in descending order');\n console.log(' -e, --expanded Use expanded version format');\n console.log(' -s, --streaming Enable streaming output');\n console.log(' --silent Suppress logging');\n console.log('');\n console.log('Examples:');\n console.log(` ${name} 22 node --version Run with Node 22`);\n console.log(` ${name} 22,20,18 npm test Run with multiple versions`);\n console.log(` ${name} engines node --version Use version from package.json`);\n console.log(` ${name} default 20 Set global default to Node 20`);\n console.log(` ${name} local 18 Create .nvmrc with Node 18`);\n}\n\nexport default (argv: string[], name: string): undefined => {\n const options = getopts(argv, {\n alias: { range: 'r', desc: 'd', expanded: 'e', streaming: 's', silent: 'si', version: 'v', help: 'h' },\n default: { range: 'major,even', interactive: true },\n boolean: ['silent', 'desc', 'expanded', 'streaming', 'interactive', 'version', 'help'],\n stopEarly: true,\n });\n\n if (options.version) {\n console.log(getVersion());\n exit(0);\n return;\n }\n\n if (options.help) {\n printHelp(name);\n exit(0);\n return;\n }\n\n // Check if first argument is a subcommand\n const args = options._;\n if (args.length > 0 && isCommand(args[0])) {\n runCommand(args[0], args.slice(1));\n return;\n }\n\n // define.option('-r, --range [range]', 'range type of major, minor, or patch with filters of lts, even, odd for version string expressions', 'major,even');\n // define.option('-s, --silent', 'suppress logging', false);\n options.sort = options.desc ? -1 : 1;\n\n if (args.length === 0) {\n console.log(`Missing version expression. Example usage: ${name} version command arg1 arg2`);\n exit(ERROR_CODE);\n return;\n }\n if (args.length === 1) {\n console.log(`Missing command. Example usage: ${name} version command arg1 arg2`);\n exit(ERROR_CODE);\n return;\n }\n\n options.stdio = 'inherit'; // pass through stdio\n run(args[0], args[1], args.slice(2), options as unknown as UseOptions, (err: UseError, results: UseResult[]): undefined => {\n if (err && !err.results) {\n console.log(err.message);\n exit(ERROR_CODE);\n return;\n }\n if (err) results = err.results;\n const errors = results.filter((result) => !!result.error);\n\n if (!options.silent) {\n if (!createSession) {\n console.log('\\n======================');\n results.forEach((res) => {\n console.log(`${res.error ? figures.cross : figures.tick} ${res.version}${res.error ? ` Error: ${res.error.message}` : ''}`);\n });\n console.log('\\n----------------------');\n console.log(`${name} ${formatArguments(args).join(' ')}`);\n console.log(`${figures.tick} ${results.length - errors.length} succeeded`);\n if (errors.length) console.log(`${figures.cross} ${errors.length} failed`);\n }\n }\n exit(err || errors.length ? ERROR_CODE : 0);\n });\n};\n"],"names":["__dirname","path","dirname","__filename","url","fileURLToPath","ERROR_CODE","getVersion","packagePath","join","packageJson","JSON","parse","fs","readFileSync","version","printHelp","name","console","log","argv","options","getopts","alias","range","desc","expanded","streaming","silent","help","default","interactive","boolean","stopEarly","exit","args","_","length","isCommand","runCommand","slice","sort","stdio","run","err","results","message","errors","filter","result","error","createSession","forEach","res","figures","cross","tick","formatArguments"],"mappings":";;;;+BAyDA;;;eAAA;;;2DAzDiB;yDACF;oEACK;2DACH;yBACuC;0DACxC;uBACsB;+DACtB;;;;;;AAGhB,IAAMA,YAAYC,aAAI,CAACC,OAAO,CAAC,OAAOC,eAAe,cAAcA,aAAaC,YAAG,CAACC,aAAa,CAAC;AAElG,IAAMC,aAAa;AAEnB,SAASC;IACP,IAAMC,cAAcP,aAAI,CAACQ,IAAI,CAACT,WAAW,MAAM,MAAM;IACrD,IAAMU,cAAcC,KAAKC,KAAK,CAACC,WAAE,CAACC,YAAY,CAACN,aAAa;IAC5D,OAAOE,YAAYK,OAAO;AAC5B;AAEA,SAASC,UAAUC,IAAY;IAC7B,IAAMF,UAAUR;IAChBW,QAAQC,GAAG,CAAC,AAAC,GAAWJ,OAATE,MAAK,MAAY,OAARF;IACxBG,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC,AAAC,UAAc,OAALF,MAAK;IAC3BC,QAAQC,GAAG,CAAC,AAAC,UAAc,OAALF,MAAK;IAC3BC,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;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AO,CAACE,IAAI,EAAC,KAAiBH,OAAdA,IAAItC,OAAO,EAAmD,OAAhDsC,IAAIH,KAAK,GAAG,AAAC,WAA4B,OAAlBG,IAAIH,KAAK,CAACJ,OAAO,IAAK;gBACxH;gBACA5B,QAAQC,GAAG,CAAC;gBACZD,QAAQC,GAAG,CAAC,AAAC,GAAUsC,OAARxC,MAAK,KAAmC,OAAhCwC,IAAAA,0BAAe,EAACtB,MAAM1B,IAAI,CAAC;gBAClDS,QAAQC,GAAG,CAAC,AAAC,GAAkB0B,OAAhBS,kBAAO,CAACE,IAAI,EAAC,KAAkC,OAA/BX,QAAQR,MAAM,GAAGU,OAAOV,MAAM,EAAC;gBAC9D,IAAIU,OAAOV,MAAM,EAAEnB,QAAQC,GAAG,CAAC,AAAC,GAAmB4B,OAAjBO,kBAAO,CAACC,KAAK,EAAC,KAAiB,OAAdR,OAAOV,MAAM,EAAC;YACnE;QACF;QACAH,IAAAA,aAAI,EAACU,OAAOG,OAAOV,MAAM,GAAG/B,aAAa;IAC3C;AACF"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/cli.ts"],"sourcesContent":["import exit from 'exit-compat';\nimport fs from 'fs';\nimport getopts from 'getopts-compat';\nimport path from 'path';\nimport { createSession, figures, formatArguments } from 'spawn-term';\nimport url from 'url';\nimport { isCommand, runCommand } from './commands/index.ts';\nimport run from './index.ts';\nimport type { UseError, UseOptions, UseResult } from './types.ts';\n\nconst __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url));\n\nconst ERROR_CODE = 13;\n\nfunction getVersion(): string {\n const packagePath = path.join(__dirname, '..', '..', 'package.json');\n const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf8'));\n return packageJson.version;\n}\n\nfunction printHelp(name: string): void {\n const version = getVersion();\n console.log(`${name} v${version}`);\n console.log('');\n console.log(`Usage: ${name} [options] <version> <command> [args...]`);\n console.log(` ${name} <subcommand> [args...]`);\n console.log('');\n console.log('Run commands with specific Node.js versions');\n console.log('');\n console.log('Subcommands:');\n console.log(' default [version] Set or display the global default Node version');\n console.log(' local [version] Set or display the local Node version (.nvmrc)');\n console.log(' install <version> Download and install a Node version');\n console.log(' uninstall <version> Remove an installed Node version');\n console.log(' list List installed Node versions');\n console.log(' which Show which Node version would be used');\n console.log(' setup Install/reinstall binaries to ~/.nvu/bin');\n console.log(' teardown Remove binaries from ~/.nvu/bin');\n console.log('');\n console.log('Options:');\n console.log(' -v, --version Print version number');\n console.log(' -h, --help Print this help message');\n console.log(' -r, --range Range type (major, minor, patch) with filters (lts, even, odd)');\n console.log(' Default: major,even');\n console.log(' -d, --desc Sort versions in descending order');\n console.log(' -e, --expanded Use expanded version format');\n console.log(' -s, --streaming Enable streaming output');\n console.log(' --silent Suppress logging');\n console.log('');\n console.log('Examples:');\n console.log(` ${name} 22 node --version Run with Node 22`);\n console.log(` ${name} 22,20,18 npm test Run with multiple versions`);\n console.log(` ${name} engines node --version Use version from package.json`);\n console.log(` ${name} default 20 Set global default to Node 20`);\n console.log(` ${name} local 18 Create .nvmrc with Node 18`);\n}\n\nexport default (argv: string[], name: string): undefined => {\n const options = getopts(argv, {\n alias: { range: 'r', desc: 'd', expanded: 'e', streaming: 's', silent: 'si', version: 'v', help: 'h' },\n default: { range: 'major,even', interactive: true },\n boolean: ['silent', 'desc', 'expanded', 'streaming', 'interactive', 'version', 'help'],\n stopEarly: true,\n });\n\n if (options.version) {\n console.log(getVersion());\n exit(0);\n return;\n }\n\n if (options.help) {\n printHelp(name);\n exit(0);\n return;\n }\n\n // Check if first argument is a subcommand\n const args = options._;\n if (args.length > 0 && isCommand(args[0])) {\n runCommand(args[0], args.slice(1));\n return;\n }\n\n // define.option('-r, --range [range]', 'range type of major, minor, or patch with filters of lts, even, odd for version string expressions', 'major,even');\n // define.option('-s, --silent', 'suppress logging', false);\n options.sort = options.desc ? -1 : 1;\n\n if (args.length === 0) {\n console.log(`Missing version expression. Example usage: ${name} version command arg1 arg2`);\n exit(ERROR_CODE);\n return;\n }\n if (args.length === 1) {\n console.log(`Missing command. Example usage: ${name} version command arg1 arg2`);\n exit(ERROR_CODE);\n return;\n }\n\n options.stdio = 'inherit'; // pass through stdio\n run(args[0], args[1], args.slice(2), options as unknown as UseOptions, (err: UseError, results: UseResult[]): undefined => {\n if (err && !err.results) {\n console.log(err.message);\n exit(ERROR_CODE);\n return;\n }\n if (err) results = err.results;\n const errors = results.filter((result) => !!result.error);\n\n if (!options.silent) {\n if (!createSession) {\n console.log('\\n======================');\n results.forEach((res) => {\n console.log(`${res.error ? figures.cross : figures.tick} ${res.version}${res.error ? ` Error: ${res.error.message}` : ''}`);\n });\n console.log('\\n----------------------');\n console.log(`${name} ${formatArguments(args).join(' ')}`);\n console.log(`${figures.tick} ${results.length - errors.length} succeeded`);\n if (errors.length) console.log(`${figures.cross} ${errors.length} failed`);\n }\n }\n exit(err || errors.length ? ERROR_CODE : 0);\n });\n};\n"],"names":["__dirname","path","dirname","__filename","url","fileURLToPath","ERROR_CODE","getVersion","packagePath","join","packageJson","JSON","parse","fs","readFileSync","version","printHelp","name","console","log","argv","options","getopts","alias","range","desc","expanded","streaming","silent","help","default","interactive","boolean","stopEarly","exit","args","_","length","isCommand","runCommand","slice","sort","stdio","run","err","results","message","errors","filter","result","error","createSession","forEach","res","figures","cross","tick","formatArguments"],"mappings":";;;;+BAyDA;;;eAAA;;;iEAzDiB;yDACF;oEACK;2DACH;yBACuC;0DACxC;uBACsB;+DACtB;;;;;;AAGhB,IAAMA,YAAYC,aAAI,CAACC,OAAO,CAAC,OAAOC,eAAe,cAAcA,aAAaC,YAAG,CAACC,aAAa,CAAC;AAElG,IAAMC,aAAa;AAEnB,SAASC;IACP,IAAMC,cAAcP,aAAI,CAACQ,IAAI,CAACT,WAAW,MAAM,MAAM;IACrD,IAAMU,cAAcC,KAAKC,KAAK,CAACC,WAAE,CAACC,YAAY,CAACN,aAAa;IAC5D,OAAOE,YAAYK,OAAO;AAC5B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EAAC5B;YACL;QACF;QACA,IAAIsC,KAAKC,UAAUD,IAAIC,OAAO;QAC9B,IAAME,SAASF,QAAQG,MAAM,CAAC,SAACC;mBAAW,CAAC,CAACA,OAAOC,KAAK;;QAExD,IAAI,CAAC7B,QAAQO,MAAM,EAAE;YACnB,IAAI,CAACuB,wBAAa,EAAE;gBAClBjC,QAAQC,GAAG,CAAC;gBACZ0B,QAAQO,OAAO,CAAC,SAACC;oBACfnC,QAAQC,GAAG,CAAC,AAAC,GAA8CkC,OAA5CA,IAAIH,KAAK,GAAGI,kBAAO,CAACC,KAAK,GAAGD,kBAAO,CAACE,IAAI,EAAC,KAAiBH,OAAdA,IAAItC,OAAO,EAAmD,OAAhDsC,IAAIH,KAAK,GAAG,AAAC,WAA4B,OAAlBG,IAAIH,KAAK,CAACJ,OAAO,IAAK;gBACxH;gBACA5B,QAAQC,GAAG,CAAC;gBACZD,QAAQC,GAAG,CAAC,AAAC,GAAUsC,OAARxC,MAAK,KAAmC,OAAhCwC,IAAAA,0BAAe,EAACtB,MAAM1B,IAAI,CAAC;gBAClDS,QAAQC,GAAG,CAAC,AAAC,GAAkB0B,OAAhBS,kBAAO,CAACE,IAAI,EAAC,KAAkC,OAA/BX,QAAQR,MAAM,GAAGU,OAAOV,MAAM,EAAC;gBAC9D,IAAIU,OAAOV,MAAM,EAAEnB,QAAQC,GAAG,CAAC,AAAC,GAAmB4B,OAAjBO,kBAAO,CAACC,KAAK,EAAC,KAAiB,OAAdR,OAAOV,MAAM,EAAC;YACnE;QACF;QACAH,IAAAA,mBAAI,EAACU,OAAOG,OAAOV,MAAM,GAAG/B,aAAa;IAC3C;AACF"}
@@ -13,7 +13,7 @@ Object.defineProperty(exports, /**
13
13
  return defaultCmd;
14
14
  }
15
15
  });
16
- var _exit = /*#__PURE__*/ _interop_require_default(require("exit"));
16
+ var _exitcompat = /*#__PURE__*/ _interop_require_default(require("exit-compat"));
17
17
  var _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
18
18
  var _path = /*#__PURE__*/ _interop_require_default(require("path"));
19
19
  var _compatts = require("../compat.js");
@@ -34,7 +34,7 @@ function defaultCmd(args) {
34
34
  console.log('No default version set.');
35
35
  console.log('Usage: nvu default <version>');
36
36
  }
37
- (0, _exit.default)(0);
37
+ (0, _exitcompat.default)(0);
38
38
  return;
39
39
  }
40
40
  var version = args[0].trim();
@@ -42,7 +42,7 @@ function defaultCmd(args) {
42
42
  if (!version || version.indexOf('-') === 0) {
43
43
  console.log('Usage: nvu default <version>');
44
44
  console.log('Example: nvu default 20');
45
- (0, _exit.default)(1);
45
+ (0, _exitcompat.default)(1);
46
46
  return;
47
47
  }
48
48
  // Ensure storage directory exists
@@ -52,6 +52,6 @@ function defaultCmd(args) {
52
52
  // Write the default version
53
53
  _fs.default.writeFileSync(defaultFilePath, "".concat(version, "\n"), 'utf8');
54
54
  console.log("Default Node version set to: ".concat(version));
55
- (0, _exit.default)(0);
55
+ (0, _exitcompat.default)(0);
56
56
  }
57
57
  /* 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; }
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/default.ts"],"sourcesContent":["import exit from 'exit';\nimport fs from 'fs';\nimport path from 'path';\nimport { mkdirpSync } from '../compat.ts';\nimport { storagePath } from '../constants.ts';\n\n/**\n * nvu default [version]\n *\n * Set or display the global default Node version.\n * This is used when no .nvmrc or .nvurc is found in the project.\n */\nexport default function defaultCmd(args: string[]): void {\n var defaultFilePath = path.join(storagePath, 'default');\n\n // If no version provided, display current default\n if (args.length === 0) {\n if (fs.existsSync(defaultFilePath)) {\n var currentVersion = fs.readFileSync(defaultFilePath, 'utf8').trim();\n console.log(`Current default: ${currentVersion}`);\n } else {\n console.log('No default version set.');\n console.log('Usage: nvu default <version>');\n }\n exit(0);\n return;\n }\n\n var version = args[0].trim();\n\n // Validate version format (basic check, indexOf for Node 0.8+ compat)\n if (!version || version.indexOf('-') === 0) {\n console.log('Usage: nvu default <version>');\n console.log('Example: nvu default 20');\n exit(1);\n return;\n }\n\n // Ensure storage directory exists\n if (!fs.existsSync(storagePath)) {\n mkdirpSync(storagePath);\n }\n\n // Write the default version\n fs.writeFileSync(defaultFilePath, `${version}\\n`, 'utf8');\n console.log(`Default Node version set to: ${version}`);\n exit(0);\n}\n"],"names":["defaultCmd","args","defaultFilePath","path","join","storagePath","length","fs","existsSync","currentVersion","readFileSync","trim","console","log","exit","version","indexOf","mkdirpSync","writeFileSync"],"mappings":";;;;+BAMA;;;;;CAKC,GACD;;;eAAwBA;;;2DAZP;yDACF;2DACE;wBACU;2BACC;;;;;;AAQb,SAASA,WAAWC,IAAc;IAC/C,IAAIC,kBAAkBC,aAAI,CAACC,IAAI,CAACC,wBAAW,EAAE;IAE7C,kDAAkD;IAClD,IAAIJ,KAAKK,MAAM,KAAK,GAAG;QACrB,IAAIC,WAAE,CAACC,UAAU,CAACN,kBAAkB;YAClC,IAAIO,iBAAiBF,WAAE,CAACG,YAAY,CAACR,iBAAiB,QAAQS,IAAI;YAClEC,QAAQC,GAAG,CAAC,AAAC,oBAAkC,OAAfJ;QAClC,OAAO;YACLG,QAAQC,GAAG,CAAC;YACZD,QAAQC,GAAG,CAAC;QACd;QACAC,IAAAA,aAAI,EAAC;QACL;IACF;IAEA,IAAIC,UAAUd,IAAI,CAAC,EAAE,CAACU,IAAI;IAE1B,sEAAsE;IACtE,IAAI,CAACI,WAAWA,QAAQC,OAAO,CAAC,SAAS,GAAG;QAC1CJ,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZC,IAAAA,aAAI,EAAC;QACL;IACF;IAEA,kCAAkC;IAClC,IAAI,CAACP,WAAE,CAACC,UAAU,CAACH,wBAAW,GAAG;QAC/BY,IAAAA,oBAAU,EAACZ,wBAAW;IACxB;IAEA,4BAA4B;IAC5BE,WAAE,CAACW,aAAa,CAAChB,iBAAiB,AAAC,GAAU,OAARa,SAAQ,OAAK;IAClDH,QAAQC,GAAG,CAAC,AAAC,gCAAuC,OAARE;IAC5CD,IAAAA,aAAI,EAAC;AACP"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/default.ts"],"sourcesContent":["import exit from 'exit-compat';\nimport fs from 'fs';\nimport path from 'path';\nimport { mkdirpSync } from '../compat.ts';\nimport { storagePath } from '../constants.ts';\n\n/**\n * nvu default [version]\n *\n * Set or display the global default Node version.\n * This is used when no .nvmrc or .nvurc is found in the project.\n */\nexport default function defaultCmd(args: string[]): void {\n var defaultFilePath = path.join(storagePath, 'default');\n\n // If no version provided, display current default\n if (args.length === 0) {\n if (fs.existsSync(defaultFilePath)) {\n var currentVersion = fs.readFileSync(defaultFilePath, 'utf8').trim();\n console.log(`Current default: ${currentVersion}`);\n } else {\n console.log('No default version set.');\n console.log('Usage: nvu default <version>');\n }\n exit(0);\n return;\n }\n\n var version = args[0].trim();\n\n // Validate version format (basic check, indexOf for Node 0.8+ compat)\n if (!version || version.indexOf('-') === 0) {\n console.log('Usage: nvu default <version>');\n console.log('Example: nvu default 20');\n exit(1);\n return;\n }\n\n // Ensure storage directory exists\n if (!fs.existsSync(storagePath)) {\n mkdirpSync(storagePath);\n }\n\n // Write the default version\n fs.writeFileSync(defaultFilePath, `${version}\\n`, 'utf8');\n console.log(`Default Node version set to: ${version}`);\n exit(0);\n}\n"],"names":["defaultCmd","args","defaultFilePath","path","join","storagePath","length","fs","existsSync","currentVersion","readFileSync","trim","console","log","exit","version","indexOf","mkdirpSync","writeFileSync"],"mappings":";;;;+BAMA;;;;;CAKC,GACD;;;eAAwBA;;;iEAZP;yDACF;2DACE;wBACU;2BACC;;;;;;AAQb,SAASA,WAAWC,IAAc;IAC/C,IAAIC,kBAAkBC,aAAI,CAACC,IAAI,CAACC,wBAAW,EAAE;IAE7C,kDAAkD;IAClD,IAAIJ,KAAKK,MAAM,KAAK,GAAG;QACrB,IAAIC,WAAE,CAACC,UAAU,CAACN,kBAAkB;YAClC,IAAIO,iBAAiBF,WAAE,CAACG,YAAY,CAACR,iBAAiB,QAAQS,IAAI;YAClEC,QAAQC,GAAG,CAAC,AAAC,oBAAkC,OAAfJ;QAClC,OAAO;YACLG,QAAQC,GAAG,CAAC;YACZD,QAAQC,GAAG,CAAC;QACd;QACAC,IAAAA,mBAAI,EAAC;QACL;IACF;IAEA,IAAIC,UAAUd,IAAI,CAAC,EAAE,CAACU,IAAI;IAE1B,sEAAsE;IACtE,IAAI,CAACI,WAAWA,QAAQC,OAAO,CAAC,SAAS,GAAG;QAC1CJ,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZC,IAAAA,mBAAI,EAAC;QACL;IACF;IAEA,kCAAkC;IAClC,IAAI,CAACP,WAAE,CAACC,UAAU,CAACH,wBAAW,GAAG;QAC/BY,IAAAA,oBAAU,EAACZ,wBAAW;IACxB;IAEA,4BAA4B;IAC5BE,WAAE,CAACW,aAAa,CAAChB,iBAAiB,AAAC,GAAU,OAARa,SAAQ,OAAK;IAClDH,QAAQC,GAAG,CAAC,AAAC,gCAAuC,OAARE;IAC5CD,IAAAA,mBAAI,EAAC;AACP"}
@@ -12,7 +12,7 @@ Object.defineProperty(exports, /**
12
12
  return installCmd;
13
13
  }
14
14
  });
15
- var _exit = /*#__PURE__*/ _interop_require_default(require("exit"));
15
+ var _exitcompat = /*#__PURE__*/ _interop_require_default(require("exit-compat"));
16
16
  var _path = /*#__PURE__*/ _interop_require_default(require("path"));
17
17
  var _constantsts = require("../constants.js");
18
18
  var _loadNodeVersionInstallts = /*#__PURE__*/ _interop_require_default(require("../lib/loadNodeVersionInstall.js"));
@@ -27,14 +27,14 @@ function installCmd(args) {
27
27
  console.log('Example: nvu install 20');
28
28
  console.log(' nvu install 20.10.0');
29
29
  console.log(' nvu install lts');
30
- (0, _exit.default)(1);
30
+ (0, _exitcompat.default)(1);
31
31
  return;
32
32
  }
33
33
  var version = args[0].trim();
34
34
  // Validate version format (basic check, indexOf for Node 0.8+ compat)
35
35
  if (!version || version.indexOf('-') === 0) {
36
36
  console.log('Usage: nvu install <version>');
37
- (0, _exit.default)(1);
37
+ (0, _exitcompat.default)(1);
38
38
  return;
39
39
  }
40
40
  console.log("Installing Node ".concat(version, "..."));
@@ -43,7 +43,7 @@ function installCmd(args) {
43
43
  if (err || !nodeVersionInstall) {
44
44
  console.error('Failed to load node-version-install:', (err === null || err === void 0 ? void 0 : err.message) || 'Module not available');
45
45
  console.error('Make sure node-version-install is installed: npm install node-version-install');
46
- (0, _exit.default)(1);
46
+ (0, _exitcompat.default)(1);
47
47
  return;
48
48
  }
49
49
  var versionsPath = _path.default.join(_constantsts.storagePath, 'installed');
@@ -52,7 +52,7 @@ function installCmd(args) {
52
52
  }, function(installErr, results) {
53
53
  if (installErr) {
54
54
  console.error("Failed to install Node ".concat(version, ":"), installErr.message);
55
- (0, _exit.default)(1);
55
+ (0, _exitcompat.default)(1);
56
56
  return;
57
57
  }
58
58
  if (results && results.length > 0) {
@@ -62,7 +62,7 @@ function installCmd(args) {
62
62
  } else {
63
63
  console.log("Node ".concat(version, " installed successfully."));
64
64
  }
65
- (0, _exit.default)(0);
65
+ (0, _exitcompat.default)(0);
66
66
  });
67
67
  });
68
68
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/install.ts"],"sourcesContent":["import exit from 'exit';\nimport path from 'path';\nimport { storagePath } from '../constants.ts';\nimport loadNodeVersionInstall from '../lib/loadNodeVersionInstall.ts';\n\n/**\n * nvu install <version>\n *\n * Download and install a specific Node version.\n */\nexport default function installCmd(args: string[]): void {\n if (args.length === 0) {\n console.log('Usage: nvu install <version>');\n console.log('Example: nvu install 20');\n console.log(' nvu install 20.10.0');\n console.log(' nvu install lts');\n exit(1);\n return;\n }\n\n const version = args[0].trim();\n\n // Validate version format (basic check, indexOf for Node 0.8+ compat)\n if (!version || version.indexOf('-') === 0) {\n console.log('Usage: nvu install <version>');\n exit(1);\n return;\n }\n\n console.log(`Installing Node ${version}...`);\n\n // Load node-version-install dynamically\n loadNodeVersionInstall((err, nodeVersionInstall) => {\n if (err || !nodeVersionInstall) {\n console.error('Failed to load node-version-install:', err?.message || 'Module not available');\n console.error('Make sure node-version-install is installed: npm install node-version-install');\n exit(1);\n return;\n }\n\n const versionsPath = path.join(storagePath, 'installed');\n\n nodeVersionInstall(\n version,\n {\n installPath: versionsPath,\n },\n (installErr?: Error, results?: { version: string; installPath: string }[]) => {\n if (installErr) {\n console.error(`Failed to install Node ${version}:`, installErr.message);\n exit(1);\n return;\n }\n\n if (results && results.length > 0) {\n const result = results[0];\n console.log(`Successfully installed Node ${result.version}`);\n console.log(`Location: ${result.installPath}`);\n } else {\n console.log(`Node ${version} installed successfully.`);\n }\n exit(0);\n }\n );\n });\n}\n"],"names":["installCmd","args","length","console","log","exit","version","trim","indexOf","loadNodeVersionInstall","err","nodeVersionInstall","error","message","versionsPath","path","join","storagePath","installPath","installErr","results","result"],"mappings":";;;;+BAKA;;;;CAIC,GACD;;;eAAwBA;;;2DAVP;2DACA;2BACW;+EACO;;;;;;AAOpB,SAASA,WAAWC,IAAc;IAC/C,IAAIA,KAAKC,MAAM,KAAK,GAAG;QACrBC,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZC,IAAAA,aAAI,EAAC;QACL;IACF;IAEA,IAAMC,UAAUL,IAAI,CAAC,EAAE,CAACM,IAAI;IAE5B,sEAAsE;IACtE,IAAI,CAACD,WAAWA,QAAQE,OAAO,CAAC,SAAS,GAAG;QAC1CL,QAAQC,GAAG,CAAC;QACZC,IAAAA,aAAI,EAAC;QACL;IACF;IAEAF,QAAQC,GAAG,CAAC,AAAC,mBAA0B,OAARE,SAAQ;IAEvC,wCAAwC;IACxCG,IAAAA,iCAAsB,EAAC,SAACC,KAAKC;QAC3B,IAAID,OAAO,CAACC,oBAAoB;YAC9BR,QAAQS,KAAK,CAAC,wCAAwCF,CAAAA,gBAAAA,0BAAAA,IAAKG,OAAO,KAAI;YACtEV,QAAQS,KAAK,CAAC;YACdP,IAAAA,aAAI,EAAC;YACL;QACF;QAEA,IAAMS,eAAeC,aAAI,CAACC,IAAI,CAACC,wBAAW,EAAE;QAE5CN,mBACEL,SACA;YACEY,aAAaJ;QACf,GACA,SAACK,YAAoBC;YACnB,IAAID,YAAY;gBACdhB,QAAQS,KAAK,CAAC,AAAC,0BAAiC,OAARN,SAAQ,MAAIa,WAAWN,OAAO;gBACtER,IAAAA,aAAI,EAAC;gBACL;YACF;YAEA,IAAIe,WAAWA,QAAQlB,MAAM,GAAG,GAAG;gBACjC,IAAMmB,SAASD,OAAO,CAAC,EAAE;gBACzBjB,QAAQC,GAAG,CAAC,AAAC,+BAA6C,OAAfiB,OAAOf,OAAO;gBACzDH,QAAQC,GAAG,CAAC,AAAC,aAA+B,OAAnBiB,OAAOH,WAAW;YAC7C,OAAO;gBACLf,QAAQC,GAAG,CAAC,AAAC,QAAe,OAARE,SAAQ;YAC9B;YACAD,IAAAA,aAAI,EAAC;QACP;IAEJ;AACF"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/install.ts"],"sourcesContent":["import exit from 'exit-compat';\nimport path from 'path';\nimport { storagePath } from '../constants.ts';\nimport loadNodeVersionInstall from '../lib/loadNodeVersionInstall.ts';\n\n/**\n * nvu install <version>\n *\n * Download and install a specific Node version.\n */\nexport default function installCmd(args: string[]): void {\n if (args.length === 0) {\n console.log('Usage: nvu install <version>');\n console.log('Example: nvu install 20');\n console.log(' nvu install 20.10.0');\n console.log(' nvu install lts');\n exit(1);\n return;\n }\n\n const version = args[0].trim();\n\n // Validate version format (basic check, indexOf for Node 0.8+ compat)\n if (!version || version.indexOf('-') === 0) {\n console.log('Usage: nvu install <version>');\n exit(1);\n return;\n }\n\n console.log(`Installing Node ${version}...`);\n\n // Load node-version-install dynamically\n loadNodeVersionInstall((err, nodeVersionInstall) => {\n if (err || !nodeVersionInstall) {\n console.error('Failed to load node-version-install:', err?.message || 'Module not available');\n console.error('Make sure node-version-install is installed: npm install node-version-install');\n exit(1);\n return;\n }\n\n const versionsPath = path.join(storagePath, 'installed');\n\n nodeVersionInstall(\n version,\n {\n installPath: versionsPath,\n },\n (installErr?: Error, results?: { version: string; installPath: string }[]) => {\n if (installErr) {\n console.error(`Failed to install Node ${version}:`, installErr.message);\n exit(1);\n return;\n }\n\n if (results && results.length > 0) {\n const result = results[0];\n console.log(`Successfully installed Node ${result.version}`);\n console.log(`Location: ${result.installPath}`);\n } else {\n console.log(`Node ${version} installed successfully.`);\n }\n exit(0);\n }\n );\n });\n}\n"],"names":["installCmd","args","length","console","log","exit","version","trim","indexOf","loadNodeVersionInstall","err","nodeVersionInstall","error","message","versionsPath","path","join","storagePath","installPath","installErr","results","result"],"mappings":";;;;+BAKA;;;;CAIC,GACD;;;eAAwBA;;;iEAVP;2DACA;2BACW;+EACO;;;;;;AAOpB,SAASA,WAAWC,IAAc;IAC/C,IAAIA,KAAKC,MAAM,KAAK,GAAG;QACrBC,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZC,IAAAA,mBAAI,EAAC;QACL;IACF;IAEA,IAAMC,UAAUL,IAAI,CAAC,EAAE,CAACM,IAAI;IAE5B,sEAAsE;IACtE,IAAI,CAACD,WAAWA,QAAQE,OAAO,CAAC,SAAS,GAAG;QAC1CL,QAAQC,GAAG,CAAC;QACZC,IAAAA,mBAAI,EAAC;QACL;IACF;IAEAF,QAAQC,GAAG,CAAC,AAAC,mBAA0B,OAARE,SAAQ;IAEvC,wCAAwC;IACxCG,IAAAA,iCAAsB,EAAC,SAACC,KAAKC;QAC3B,IAAID,OAAO,CAACC,oBAAoB;YAC9BR,QAAQS,KAAK,CAAC,wCAAwCF,CAAAA,gBAAAA,0BAAAA,IAAKG,OAAO,KAAI;YACtEV,QAAQS,KAAK,CAAC;YACdP,IAAAA,mBAAI,EAAC;YACL;QACF;QAEA,IAAMS,eAAeC,aAAI,CAACC,IAAI,CAACC,wBAAW,EAAE;QAE5CN,mBACEL,SACA;YACEY,aAAaJ;QACf,GACA,SAACK,YAAoBC;YACnB,IAAID,YAAY;gBACdhB,QAAQS,KAAK,CAAC,AAAC,0BAAiC,OAARN,SAAQ,MAAIa,WAAWN,OAAO;gBACtER,IAAAA,mBAAI,EAAC;gBACL;YACF;YAEA,IAAIe,WAAWA,QAAQlB,MAAM,GAAG,GAAG;gBACjC,IAAMmB,SAASD,OAAO,CAAC,EAAE;gBACzBjB,QAAQC,GAAG,CAAC,AAAC,+BAA6C,OAAfiB,OAAOf,OAAO;gBACzDH,QAAQC,GAAG,CAAC,AAAC,aAA+B,OAAnBiB,OAAOH,WAAW;YAC7C,OAAO;gBACLf,QAAQC,GAAG,CAAC,AAAC,QAAe,OAARE,SAAQ;YAC9B;YACAD,IAAAA,mBAAI,EAAC;QACP;IAEJ;AACF"}
@@ -12,7 +12,7 @@ Object.defineProperty(exports, /**
12
12
  return listCmd;
13
13
  }
14
14
  });
15
- var _exit = /*#__PURE__*/ _interop_require_default(require("exit"));
15
+ var _exitcompat = /*#__PURE__*/ _interop_require_default(require("exit-compat"));
16
16
  var _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
17
17
  var _path = /*#__PURE__*/ _interop_require_default(require("path"));
18
18
  var _compatts = require("../compat.js");
@@ -28,7 +28,7 @@ function listCmd(_args) {
28
28
  if (!_fs.default.existsSync(versionsPath)) {
29
29
  console.log('No Node versions installed.');
30
30
  console.log('Install a version: nvu install <version>');
31
- (0, _exit.default)(0);
31
+ (0, _exitcompat.default)(0);
32
32
  return;
33
33
  }
34
34
  // Read all directories in versions folder
@@ -41,7 +41,7 @@ function listCmd(_args) {
41
41
  if (versions.length === 0) {
42
42
  console.log('No Node versions installed.');
43
43
  console.log('Install a version: nvu install <version>');
44
- (0, _exit.default)(0);
44
+ (0, _exitcompat.default)(0);
45
45
  return;
46
46
  }
47
47
  // Get the current default
@@ -72,6 +72,6 @@ function listCmd(_args) {
72
72
  var marker = isDefault ? ' (default)' : '';
73
73
  console.log(" ".concat(version).concat(marker));
74
74
  }
75
- (0, _exit.default)(0);
75
+ (0, _exitcompat.default)(0);
76
76
  }
77
77
  /* 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; }
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/list.ts"],"sourcesContent":["import exit from 'exit';\nimport fs from 'fs';\nimport path from 'path';\nimport { readdirWithTypes } from '../compat.ts';\nimport { storagePath } from '../constants.ts';\n\n/**\n * nvu list\n *\n * List all installed Node versions.\n */\nexport default function listCmd(_args: string[]): void {\n var versionsPath = path.join(storagePath, 'installed');\n\n // Check if versions directory exists\n if (!fs.existsSync(versionsPath)) {\n console.log('No Node versions installed.');\n console.log('Install a version: nvu install <version>');\n exit(0);\n return;\n }\n\n // Read all directories in versions folder\n var entries = readdirWithTypes(versionsPath);\n var versions = entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name);\n\n if (versions.length === 0) {\n console.log('No Node versions installed.');\n console.log('Install a version: nvu install <version>');\n exit(0);\n return;\n }\n\n // Get the current default\n const defaultFilePath = path.join(storagePath, 'default');\n let defaultVersion = '';\n if (fs.existsSync(defaultFilePath)) {\n defaultVersion = fs.readFileSync(defaultFilePath, 'utf8').trim();\n }\n\n // Sort versions (simple string sort, could be improved with semver)\n versions.sort((a, b) => {\n const aParts = a.split('.').map((n) => parseInt(n, 10) || 0);\n const bParts = b.split('.').map((n) => parseInt(n, 10) || 0);\n for (let i = 0; i < Math.max(aParts.length, bParts.length); i++) {\n const aVal = aParts[i] || 0;\n const bVal = bParts[i] || 0;\n if (aVal !== bVal) return bVal - aVal; // Descending order\n }\n return 0;\n });\n\n console.log('Installed Node versions:');\n for (let i = 0; i < versions.length; i++) {\n const version = versions[i];\n const isDefault = version === defaultVersion || `v${version}` === defaultVersion || version === `v${defaultVersion}`;\n const marker = isDefault ? ' (default)' : '';\n console.log(` ${version}${marker}`);\n }\n exit(0);\n}\n"],"names":["listCmd","_args","versionsPath","path","join","storagePath","fs","existsSync","console","log","exit","entries","readdirWithTypes","versions","filter","entry","isDirectory","map","name","length","defaultFilePath","defaultVersion","readFileSync","trim","sort","a","b","aParts","split","n","parseInt","bParts","i","Math","max","aVal","bVal","version","isDefault","marker"],"mappings":";;;;+BAMA;;;;CAIC,GACD;;;eAAwBA;;;2DAXP;yDACF;2DACE;wBACgB;2BACL;;;;;;AAOb,SAASA,QAAQC,KAAe;IAC7C,IAAIC,eAAeC,aAAI,CAACC,IAAI,CAACC,wBAAW,EAAE;IAE1C,qCAAqC;IACrC,IAAI,CAACC,WAAE,CAACC,UAAU,CAACL,eAAe;QAChCM,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZC,IAAAA,aAAI,EAAC;QACL;IACF;IAEA,0CAA0C;IAC1C,IAAIC,UAAUC,IAAAA,0BAAgB,EAACV;IAC/B,IAAIW,WAAWF,QAAQG,MAAM,CAAC,SAACC;eAAUA,MAAMC,WAAW;OAAIC,GAAG,CAAC,SAACF;eAAUA,MAAMG,IAAI;;IAEvF,IAAIL,SAASM,MAAM,KAAK,GAAG;QACzBX,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZC,IAAAA,aAAI,EAAC;QACL;IACF;IAEA,0BAA0B;IAC1B,IAAMU,kBAAkBjB,aAAI,CAACC,IAAI,CAACC,wBAAW,EAAE;IAC/C,IAAIgB,iBAAiB;IACrB,IAAIf,WAAE,CAACC,UAAU,CAACa,kBAAkB;QAClCC,iBAAiBf,WAAE,CAACgB,YAAY,CAACF,iBAAiB,QAAQG,IAAI;IAChE;IAEA,oEAAoE;IACpEV,SAASW,IAAI,CAAC,SAACC,GAAGC;QAChB,IAAMC,SAASF,EAAEG,KAAK,CAAC,KAAKX,GAAG,CAAC,SAACY;mBAAMC,SAASD,GAAG,OAAO;;QAC1D,IAAME,SAASL,EAAEE,KAAK,CAAC,KAAKX,GAAG,CAAC,SAACY;mBAAMC,SAASD,GAAG,OAAO;;QAC1D,IAAK,IAAIG,IAAI,GAAGA,IAAIC,KAAKC,GAAG,CAACP,OAAOR,MAAM,EAAEY,OAAOZ,MAAM,GAAGa,IAAK;YAC/D,IAAMG,OAAOR,MAAM,CAACK,EAAE,IAAI;YAC1B,IAAMI,OAAOL,MAAM,CAACC,EAAE,IAAI;YAC1B,IAAIG,SAASC,MAAM,OAAOA,OAAOD,MAAM,mBAAmB;QAC5D;QACA,OAAO;IACT;IAEA3B,QAAQC,GAAG,CAAC;IACZ,IAAK,IAAIuB,IAAI,GAAGA,IAAInB,SAASM,MAAM,EAAEa,IAAK;QACxC,IAAMK,UAAUxB,QAAQ,CAACmB,EAAE;QAC3B,IAAMM,YAAYD,YAAYhB,kBAAkB,AAAC,IAAW,OAARgB,aAAchB,kBAAkBgB,YAAY,AAAC,IAAkB,OAAfhB;QACpG,IAAMkB,SAASD,YAAY,eAAe;QAC1C9B,QAAQC,GAAG,CAAC,AAAC,KAAc8B,OAAVF,SAAiB,OAAPE;IAC7B;IACA7B,IAAAA,aAAI,EAAC;AACP"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/list.ts"],"sourcesContent":["import exit from 'exit-compat';\nimport fs from 'fs';\nimport path from 'path';\nimport { readdirWithTypes } from '../compat.ts';\nimport { storagePath } from '../constants.ts';\n\n/**\n * nvu list\n *\n * List all installed Node versions.\n */\nexport default function listCmd(_args: string[]): void {\n var versionsPath = path.join(storagePath, 'installed');\n\n // Check if versions directory exists\n if (!fs.existsSync(versionsPath)) {\n console.log('No Node versions installed.');\n console.log('Install a version: nvu install <version>');\n exit(0);\n return;\n }\n\n // Read all directories in versions folder\n var entries = readdirWithTypes(versionsPath);\n var versions = entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name);\n\n if (versions.length === 0) {\n console.log('No Node versions installed.');\n console.log('Install a version: nvu install <version>');\n exit(0);\n return;\n }\n\n // Get the current default\n const defaultFilePath = path.join(storagePath, 'default');\n let defaultVersion = '';\n if (fs.existsSync(defaultFilePath)) {\n defaultVersion = fs.readFileSync(defaultFilePath, 'utf8').trim();\n }\n\n // Sort versions (simple string sort, could be improved with semver)\n versions.sort((a, b) => {\n const aParts = a.split('.').map((n) => parseInt(n, 10) || 0);\n const bParts = b.split('.').map((n) => parseInt(n, 10) || 0);\n for (let i = 0; i < Math.max(aParts.length, bParts.length); i++) {\n const aVal = aParts[i] || 0;\n const bVal = bParts[i] || 0;\n if (aVal !== bVal) return bVal - aVal; // Descending order\n }\n return 0;\n });\n\n console.log('Installed Node versions:');\n for (let i = 0; i < versions.length; i++) {\n const version = versions[i];\n const isDefault = version === defaultVersion || `v${version}` === defaultVersion || version === `v${defaultVersion}`;\n const marker = isDefault ? ' (default)' : '';\n console.log(` ${version}${marker}`);\n }\n exit(0);\n}\n"],"names":["listCmd","_args","versionsPath","path","join","storagePath","fs","existsSync","console","log","exit","entries","readdirWithTypes","versions","filter","entry","isDirectory","map","name","length","defaultFilePath","defaultVersion","readFileSync","trim","sort","a","b","aParts","split","n","parseInt","bParts","i","Math","max","aVal","bVal","version","isDefault","marker"],"mappings":";;;;+BAMA;;;;CAIC,GACD;;;eAAwBA;;;iEAXP;yDACF;2DACE;wBACgB;2BACL;;;;;;AAOb,SAASA,QAAQC,KAAe;IAC7C,IAAIC,eAAeC,aAAI,CAACC,IAAI,CAACC,wBAAW,EAAE;IAE1C,qCAAqC;IACrC,IAAI,CAACC,WAAE,CAACC,UAAU,CAACL,eAAe;QAChCM,QAAQC,GAAG,CAAC;QACZD,Q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,YAAYD,YAAYhB,kBAAkB,AAAC,IAAW,OAARgB,aAAchB,kBAAkBgB,YAAY,AAAC,IAAkB,OAAfhB;QACpG,IAAMkB,SAASD,YAAY,eAAe;QAC1C9B,QAAQC,GAAG,CAAC,AAAC,KAAc8B,OAAVF,SAAiB,OAAPE;IAC7B;IACA7B,IAAAA,mBAAI,EAAC;AACP"}
@@ -13,7 +13,7 @@ Object.defineProperty(exports, /**
13
13
  return localCmd;
14
14
  }
15
15
  });
16
- var _exit = /*#__PURE__*/ _interop_require_default(require("exit"));
16
+ var _exitcompat = /*#__PURE__*/ _interop_require_default(require("exit-compat"));
17
17
  var _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
18
18
  var _path = /*#__PURE__*/ _interop_require_default(require("path"));
19
19
  function _interop_require_default(obj) {
@@ -38,19 +38,19 @@ function localCmd(args) {
38
38
  if (_fs.default.existsSync(nvurcPath)) {
39
39
  var version = _fs.default.readFileSync(nvurcPath, 'utf8').trim();
40
40
  console.log("Current local version (.nvurc): ".concat(version));
41
- (0, _exit.default)(0);
41
+ (0, _exitcompat.default)(0);
42
42
  return;
43
43
  }
44
44
  if (_fs.default.existsSync(nvmrcPath)) {
45
45
  var version1 = _fs.default.readFileSync(nvmrcPath, 'utf8').trim();
46
46
  console.log("Current local version (.nvmrc): ".concat(version1));
47
- (0, _exit.default)(0);
47
+ (0, _exitcompat.default)(0);
48
48
  return;
49
49
  }
50
50
  console.log('No local version set in this directory.');
51
51
  console.log('Usage: nvu local <version>');
52
52
  console.log(' nvu local <version> --nvurc (use .nvurc instead of .nvmrc)');
53
- (0, _exit.default)(0);
53
+ (0, _exitcompat.default)(0);
54
54
  return;
55
55
  }
56
56
  var version2 = filteredArgs[0].trim();
@@ -58,12 +58,12 @@ function localCmd(args) {
58
58
  if (!version2 || version2.indexOf('-') === 0) {
59
59
  console.log('Usage: nvu local <version>');
60
60
  console.log('Example: nvu local 20');
61
- (0, _exit.default)(1);
61
+ (0, _exitcompat.default)(1);
62
62
  return;
63
63
  }
64
64
  // Write the version file
65
65
  _fs.default.writeFileSync(filePath, "".concat(version2, "\n"), 'utf8');
66
66
  console.log("Created ".concat(fileName, " with version: ").concat(version2));
67
- (0, _exit.default)(0);
67
+ (0, _exitcompat.default)(0);
68
68
  }
69
69
  /* 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; }
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/local.ts"],"sourcesContent":["import exit from 'exit';\nimport fs from 'fs';\nimport path from 'path';\n\n/**\n * nvu local [version] [--nvurc]\n *\n * Write .nvmrc (or .nvurc) to the current directory.\n * This pins the Node version for the current project.\n */\nexport default function localCmd(args: string[]): void {\n const cwd = process.cwd();\n\n // Check for --nvurc flag (indexOf for Node 0.8+ compat)\n const useNvurc = args.indexOf('--nvurc') !== -1;\n const filteredArgs = args.filter((arg) => arg !== '--nvurc');\n\n const fileName = useNvurc ? '.nvurc' : '.nvmrc';\n const filePath = path.join(cwd, fileName);\n\n // If no version provided, display current local version\n if (filteredArgs.length === 0) {\n // Check for existing version files\n const nvurcPath = path.join(cwd, '.nvurc');\n const nvmrcPath = path.join(cwd, '.nvmrc');\n\n if (fs.existsSync(nvurcPath)) {\n const version = fs.readFileSync(nvurcPath, 'utf8').trim();\n console.log(`Current local version (.nvurc): ${version}`);\n exit(0);\n return;\n }\n if (fs.existsSync(nvmrcPath)) {\n const version = fs.readFileSync(nvmrcPath, 'utf8').trim();\n console.log(`Current local version (.nvmrc): ${version}`);\n exit(0);\n return;\n }\n\n console.log('No local version set in this directory.');\n console.log('Usage: nvu local <version>');\n console.log(' nvu local <version> --nvurc (use .nvurc instead of .nvmrc)');\n exit(0);\n return;\n }\n\n const version = filteredArgs[0].trim();\n\n // Validate version format (basic check, indexOf for Node 0.8+ compat)\n if (!version || version.indexOf('-') === 0) {\n console.log('Usage: nvu local <version>');\n console.log('Example: nvu local 20');\n exit(1);\n return;\n }\n\n // Write the version file\n fs.writeFileSync(filePath, `${version}\\n`, 'utf8');\n console.log(`Created ${fileName} with version: ${version}`);\n exit(0);\n}\n"],"names":["localCmd","args","cwd","process","useNvurc","indexOf","filteredArgs","filter","arg","fileName","filePath","path","join","length","nvurcPath","nvmrcPath","fs","existsSync","version","readFileSync","trim","console","log","exit","writeFileSync"],"mappings":";;;;+BAIA;;;;;CAKC,GACD;;;eAAwBA;;;2DAVP;yDACF;2DACE;;;;;;AAQF,SAASA,SAASC,IAAc;IAC7C,IAAMC,MAAMC,QAAQD,GAAG;IAEvB,wDAAwD;IACxD,IAAME,WAAWH,KAAKI,OAAO,CAAC,eAAe,CAAC;IAC9C,IAAMC,eAAeL,KAAKM,MAAM,CAAC,SAACC;eAAQA,QAAQ;;IAElD,IAAMC,WAAWL,WAAW,WAAW;IACvC,IAAMM,WAAWC,aAAI,CAACC,IAAI,CAACV,KAAKO;IAEhC,wDAAwD;IACxD,IAAIH,aAAaO,MAAM,KAAK,GAAG;QAC7B,mCAAmC;QACnC,IAAMC,YAAYH,aAAI,CAACC,IAAI,CAACV,KAAK;QACjC,IAAMa,YAAYJ,aAAI,CAACC,IAAI,CAACV,KAAK;QAEjC,IAAIc,WAAE,CAACC,UAAU,CAACH,YAAY;YAC5B,IAAMI,UAAUF,WAAE,CAACG,YAAY,CAACL,WAAW,QAAQM,IAAI;YACvDC,QAAQC,GAAG,CAAC,AAAC,mCAA0C,OAARJ;YAC/CK,IAAAA,aAAI,EAAC;YACL;QACF;QACA,IAAIP,WAAE,CAACC,UAAU,CAACF,YAAY;YAC5B,IAAMG,WAAUF,WAAE,CAACG,YAAY,CAACJ,WAAW,QAAQK,IAAI;YACvDC,QAAQC,GAAG,CAAC,AAAC,mCAA0C,OAARJ;YAC/CK,IAAAA,aAAI,EAAC;YACL;QACF;QAEAF,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZC,IAAAA,aAAI,EAAC;QACL;IACF;IAEA,IAAML,WAAUZ,YAAY,CAAC,EAAE,CAACc,IAAI;IAEpC,sEAAsE;IACtE,IAAI,CAACF,YAAWA,SAAQb,OAAO,CAAC,SAAS,GAAG;QAC1CgB,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZC,IAAAA,aAAI,EAAC;QACL;IACF;IAEA,yBAAyB;IACzBP,WAAE,CAACQ,aAAa,CAACd,UAAU,AAAC,GAAU,OAARQ,UAAQ,OAAK;IAC3CG,QAAQC,GAAG,CAAC,AAAC,WAAoCJ,OAA1BT,UAAS,mBAAyB,OAARS;IACjDK,IAAAA,aAAI,EAAC;AACP"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/local.ts"],"sourcesContent":["import exit from 'exit-compat';\nimport fs from 'fs';\nimport path from 'path';\n\n/**\n * nvu local [version] [--nvurc]\n *\n * Write .nvmrc (or .nvurc) to the current directory.\n * This pins the Node version for the current project.\n */\nexport default function localCmd(args: string[]): void {\n const cwd = process.cwd();\n\n // Check for --nvurc flag (indexOf for Node 0.8+ compat)\n const useNvurc = args.indexOf('--nvurc') !== -1;\n const filteredArgs = args.filter((arg) => arg !== '--nvurc');\n\n const fileName = useNvurc ? '.nvurc' : '.nvmrc';\n const filePath = path.join(cwd, fileName);\n\n // If no version provided, display current local version\n if (filteredArgs.length === 0) {\n // Check for existing version files\n const nvurcPath = path.join(cwd, '.nvurc');\n const nvmrcPath = path.join(cwd, '.nvmrc');\n\n if (fs.existsSync(nvurcPath)) {\n const version = fs.readFileSync(nvurcPath, 'utf8').trim();\n console.log(`Current local version (.nvurc): ${version}`);\n exit(0);\n return;\n }\n if (fs.existsSync(nvmrcPath)) {\n const version = fs.readFileSync(nvmrcPath, 'utf8').trim();\n console.log(`Current local version (.nvmrc): ${version}`);\n exit(0);\n return;\n }\n\n console.log('No local version set in this directory.');\n console.log('Usage: nvu local <version>');\n console.log(' nvu local <version> --nvurc (use .nvurc instead of .nvmrc)');\n exit(0);\n return;\n }\n\n const version = filteredArgs[0].trim();\n\n // Validate version format (basic check, indexOf for Node 0.8+ compat)\n if (!version || version.indexOf('-') === 0) {\n console.log('Usage: nvu local <version>');\n console.log('Example: nvu local 20');\n exit(1);\n return;\n }\n\n // Write the version file\n fs.writeFileSync(filePath, `${version}\\n`, 'utf8');\n console.log(`Created ${fileName} with version: ${version}`);\n exit(0);\n}\n"],"names":["localCmd","args","cwd","process","useNvurc","indexOf","filteredArgs","filter","arg","fileName","filePath","path","join","length","nvurcPath","nvmrcPath","fs","existsSync","version","readFileSync","trim","console","log","exit","writeFileSync"],"mappings":";;;;+BAIA;;;;;CAKC,GACD;;;eAAwBA;;;iEAVP;yDACF;2DACE;;;;;;AAQF,SAASA,SAASC,IAAc;IAC7C,IAAMC,MAAMC,QAAQD,GAAG;IAEvB,wDAAwD;IACxD,IAAME,WAAWH,KAAKI,OAAO,CAAC,eAAe,CAAC;IAC9C,IAAMC,eAAeL,KAAKM,MAAM,CAAC,SAACC;eAAQA,QAAQ;;IAElD,IAAMC,WAAWL,WAAW,WAAW;IACvC,IAAMM,WAAWC,aAAI,CAACC,IAAI,CAACV,KAAKO;IAEhC,wDAAwD;IACxD,IAAIH,aAAaO,MAAM,KAAK,GAAG;QAC7B,mCAAmC;QACnC,IAAMC,YAAYH,aAAI,CAACC,IAAI,CAACV,KAAK;QACjC,IAAMa,YAAYJ,aAAI,CAACC,IAAI,CAACV,KAAK;QAEjC,IAAIc,WAAE,CAACC,UAAU,CAACH,YAAY;YAC5B,IAAMI,UAAUF,WAAE,CAACG,YAAY,CAACL,WAAW,QAAQM,IAAI;YACvDC,QAAQC,GAAG,CAAC,AAAC,mCAA0C,OAARJ;YAC/CK,IAAAA,mBAAI,EAAC;YACL;QACF;QACA,IAAIP,WAAE,CAACC,UAAU,CAACF,YAAY;YAC5B,IAAMG,WAAUF,WAAE,CAACG,YAAY,CAACJ,WAAW,QAAQK,IAAI;YACvDC,QAAQC,GAAG,CAAC,AAAC,mCAA0C,OAARJ;YAC/CK,IAAAA,mBAAI,EAAC;YACL;QACF;QAEAF,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZC,IAAAA,mBAAI,EAAC;QACL;IACF;IAEA,IAAML,WAAUZ,YAAY,CAAC,EAAE,CAACc,IAAI;IAEpC,sEAAsE;IACtE,IAAI,CAACF,YAAWA,SAAQb,OAAO,CAAC,SAAS,GAAG;QAC1CgB,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZC,IAAAA,mBAAI,EAAC;QACL;IACF;IAEA,yBAAyB;IACzBP,WAAE,CAACQ,aAAa,CAACd,UAAU,AAAC,GAAU,OAARQ,UAAQ,OAAK;IAC3CG,QAAQC,GAAG,CAAC,AAAC,WAAoCJ,OAA1BT,UAAS,mBAAyB,OAARS;IACjDK,IAAAA,mBAAI,EAAC;AACP"}
@@ -14,7 +14,7 @@ Object.defineProperty(exports, /**
14
14
  }
15
15
  });
16
16
  var _child_process = require("child_process");
17
- var _exit = /*#__PURE__*/ _interop_require_default(require("exit"));
17
+ var _exitcompat = /*#__PURE__*/ _interop_require_default(require("exit-compat"));
18
18
  var _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
19
19
  var _path = /*#__PURE__*/ _interop_require_default(require("path"));
20
20
  var _url = /*#__PURE__*/ _interop_require_default(require("url"));
@@ -49,7 +49,7 @@ function setupCmd(_args) {
49
49
  } else {
50
50
  console.log('Setup script not found.');
51
51
  console.log('Try reinstalling: npm install -g node-version-use');
52
- (0, _exit.default)(1);
52
+ (0, _exitcompat.default)(1);
53
53
  }
54
54
  }
55
55
  /* 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; }
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/setup.ts"],"sourcesContent":["import { execSync } from 'child_process';\nimport exit from 'exit';\nimport fs from 'fs';\nimport path from 'path';\nimport url from 'url';\nimport { mkdirpSync } from '../compat.ts';\nimport { storagePath } from '../constants.ts';\n\nvar __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url));\n\n/**\n * nvu setup\n *\n * Install/reinstall nvu binaries to ~/.nvu/bin\n * This runs the same logic as the postinstall script.\n */\nexport default function setupCmd(_args: string[]): void {\n var binDir = path.join(storagePath, 'bin');\n\n // Create directories\n if (!fs.existsSync(storagePath)) {\n mkdirpSync(storagePath);\n }\n if (!fs.existsSync(binDir)) {\n mkdirpSync(binDir);\n }\n\n // Find the postinstall script relative to this module\n var postinstallPath = path.join(__dirname, '..', '..', '..', 'scripts', 'postinstall.cjs');\n\n if (fs.existsSync(postinstallPath)) {\n // Run the postinstall script\n try {\n execSync(`node \"${postinstallPath}\"`, { stdio: 'inherit' });\n } catch (_err) {\n // postinstall handles its own errors gracefully\n }\n } else {\n console.log('Setup script not found.');\n console.log('Try reinstalling: npm install -g node-version-use');\n exit(1);\n }\n}\n"],"names":["setupCmd","__dirname","path","dirname","__filename","url","fileURLToPath","_args","binDir","join","storagePath","fs","existsSync","mkdirpSync","postinstallPath","execSync","stdio","_err","console","log","exit"],"mappings":";;;;+BAUA;;;;;CAKC,GACD;;;eAAwBA;;;6BAhBC;2DACR;yDACF;2DACE;0DACD;wBACW;2BACC;;;;;;AAE5B,IAAIC,YAAYC,aAAI,CAACC,OAAO,CAAC,OAAOC,eAAe,cAAcA,aAAaC,YAAG,CAACC,aAAa,CAAC;AAQjF,SAASN,SAASO,KAAe;IAC9C,IAAIC,SAASN,aAAI,CAACO,IAAI,CAACC,wBAAW,EAAE;IAEpC,qBAAqB;IACrB,IAAI,CAACC,WAAE,CAACC,UAAU,CAACF,wBAAW,GAAG;QAC/BG,IAAAA,oBAAU,EAACH,wBAAW;IACxB;IACA,IAAI,CAACC,WAAE,CAACC,UAAU,CAACJ,SAAS;QAC1BK,IAAAA,oBAAU,EAACL;IACb;IAEA,sDAAsD;IACtD,IAAIM,kBAAkBZ,aAAI,CAACO,IAAI,CAACR,WAAW,MAAM,MAAM,MAAM,WAAW;IAExE,IAAIU,WAAE,CAACC,UAAU,CAACE,kBAAkB;QAClC,6BAA6B;QAC7B,IAAI;YACFC,IAAAA,uBAAQ,EAAC,AAAC,SAAwB,OAAhBD,iBAAgB,MAAI;gBAAEE,OAAO;YAAU;QAC3D,EAAE,OAAOC,MAAM;QACb,gDAAgD;QAClD;IACF,OAAO;QACLC,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZC,IAAAA,aAAI,EAAC;IACP;AACF"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/setup.ts"],"sourcesContent":["import { execSync } from 'child_process';\nimport exit from 'exit-compat';\nimport fs from 'fs';\nimport path from 'path';\nimport url from 'url';\nimport { mkdirpSync } from '../compat.ts';\nimport { storagePath } from '../constants.ts';\n\nvar __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url));\n\n/**\n * nvu setup\n *\n * Install/reinstall nvu binaries to ~/.nvu/bin\n * This runs the same logic as the postinstall script.\n */\nexport default function setupCmd(_args: string[]): void {\n var binDir = path.join(storagePath, 'bin');\n\n // Create directories\n if (!fs.existsSync(storagePath)) {\n mkdirpSync(storagePath);\n }\n if (!fs.existsSync(binDir)) {\n mkdirpSync(binDir);\n }\n\n // Find the postinstall script relative to this module\n var postinstallPath = path.join(__dirname, '..', '..', '..', 'scripts', 'postinstall.cjs');\n\n if (fs.existsSync(postinstallPath)) {\n // Run the postinstall script\n try {\n execSync(`node \"${postinstallPath}\"`, { stdio: 'inherit' });\n } catch (_err) {\n // postinstall handles its own errors gracefully\n }\n } else {\n console.log('Setup script not found.');\n console.log('Try reinstalling: npm install -g node-version-use');\n exit(1);\n }\n}\n"],"names":["setupCmd","__dirname","path","dirname","__filename","url","fileURLToPath","_args","binDir","join","storagePath","fs","existsSync","mkdirpSync","postinstallPath","execSync","stdio","_err","console","log","exit"],"mappings":";;;;+BAUA;;;;;CAKC,GACD;;;eAAwBA;;;6BAhBC;iEACR;yDACF;2DACE;0DACD;wBACW;2BACC;;;;;;AAE5B,IAAIC,YAAYC,aAAI,CAACC,OAAO,CAAC,OAAOC,eAAe,cAAcA,aAAaC,YAAG,CAACC,aAAa,CAAC;AAQjF,SAASN,SAASO,KAAe;IAC9C,IAAIC,SAASN,aAAI,CAACO,IAAI,CAACC,wBAAW,EAAE;IAEpC,qBAAqB;IACrB,IAAI,CAACC,WAAE,CAACC,UAAU,CAACF,wBAAW,GAAG;QAC/BG,IAAAA,oBAAU,EAACH,wBAAW;IACxB;IACA,IAAI,CAACC,WAAE,CAACC,UAAU,CAACJ,SAAS;QAC1BK,IAAAA,oBAAU,EAACL;IACb;IAEA,sDAAsD;IACtD,IAAIM,kBAAkBZ,aAAI,CAACO,IAAI,CAACR,WAAW,MAAM,MAAM,MAAM,WAAW;IAExE,IAAIU,WAAE,CAACC,UAAU,CAACE,kBAAkB;QAClC,6BAA6B;QAC7B,IAAI;YACFC,IAAAA,uBAAQ,EAAC,AAAC,SAAwB,OAAhBD,iBAAgB,MAAI;gBAAEE,OAAO;YAAU;QAC3D,EAAE,OAAOC,MAAM;QACb,gDAAgD;QAClD;IACF,OAAO;QACLC,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZC,IAAAA,mBAAI,EAAC;IACP;AACF"}
@@ -12,7 +12,7 @@ Object.defineProperty(exports, /**
12
12
  return teardownCmd;
13
13
  }
14
14
  });
15
- var _exit = /*#__PURE__*/ _interop_require_default(require("exit"));
15
+ var _exitcompat = /*#__PURE__*/ _interop_require_default(require("exit-compat"));
16
16
  var _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
17
17
  var _fsremovecompat = require("fs-remove-compat");
18
18
  var _path = /*#__PURE__*/ _interop_require_default(require("path"));
@@ -47,6 +47,6 @@ function teardownCmd(_args) {
47
47
  } else {
48
48
  console.log('No binaries found to remove.');
49
49
  }
50
- (0, _exit.default)(0);
50
+ (0, _exitcompat.default)(0);
51
51
  }
52
52
  /* 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; }
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/teardown.ts"],"sourcesContent":["import exit from 'exit';\nimport fs from 'fs';\nimport { rmSync } from 'fs-remove-compat';\nimport path from 'path';\nimport { storagePath } from '../constants.ts';\n\n/**\n * nvu teardown\n *\n * Remove nvu binaries from ~/.nvu/bin\n */\nexport default function teardownCmd(_args: string[]): void {\n const binDir = path.join(storagePath, 'bin');\n\n const binaries = ['node', 'npm', 'npx'];\n const ext = process.platform === 'win32' ? '.exe' : '';\n\n let removed = 0;\n for (let i = 0; i < binaries.length; i++) {\n const binaryPath = path.join(binDir, binaries[i] + ext);\n if (fs.existsSync(binaryPath)) {\n rmSync(binaryPath, { force: true });\n removed++;\n }\n }\n\n if (removed > 0) {\n console.log(`Removed ${removed} binary(s) from ${binDir}`);\n console.log('');\n console.log('You may also want to remove ~/.nvu/bin from your PATH.');\n } else {\n console.log('No binaries found to remove.');\n }\n\n exit(0);\n}\n"],"names":["teardownCmd","_args","binDir","path","join","storagePath","binaries","ext","process","platform","removed","i","length","binaryPath","fs","existsSync","rmSync","force","console","log","exit"],"mappings":";;;;+BAMA;;;;CAIC,GACD;;;eAAwBA;;;2DAXP;yDACF;8BACQ;2DACN;2BACW;;;;;;AAOb,SAASA,YAAYC,KAAe;IACjD,IAAMC,SAASC,aAAI,CAACC,IAAI,CAACC,wBAAW,EAAE;IAEtC,IAAMC,WAAW;QAAC;QAAQ;QAAO;KAAM;IACvC,IAAMC,MAAMC,QAAQC,QAAQ,KAAK,UAAU,SAAS;IAEpD,IAAIC,UAAU;IACd,IAAK,IAAIC,IAAI,GAAGA,IAAIL,SAASM,MAAM,EAAED,IAAK;QACxC,IAAME,aAAaV,aAAI,CAACC,IAAI,CAACF,QAAQI,QAAQ,CAACK,EAAE,GAAGJ;QACnD,IAAIO,WAAE,CAACC,UAAU,CAACF,aAAa;YAC7BG,IAAAA,sBAAM,EAACH,YAAY;gBAAEI,OAAO;YAAK;YACjCP;QACF;IACF;IAEA,IAAIA,UAAU,GAAG;QACfQ,QAAQC,GAAG,CAAC,AAAC,WAAoCjB,OAA1BQ,SAAQ,oBAAyB,OAAPR;QACjDgB,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;IACd,OAAO;QACLD,QAAQC,GAAG,CAAC;IACd;IAEAC,IAAAA,aAAI,EAAC;AACP"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/teardown.ts"],"sourcesContent":["import exit from 'exit-compat';\nimport fs from 'fs';\nimport { rmSync } from 'fs-remove-compat';\nimport path from 'path';\nimport { storagePath } from '../constants.ts';\n\n/**\n * nvu teardown\n *\n * Remove nvu binaries from ~/.nvu/bin\n */\nexport default function teardownCmd(_args: string[]): void {\n const binDir = path.join(storagePath, 'bin');\n\n const binaries = ['node', 'npm', 'npx'];\n const ext = process.platform === 'win32' ? '.exe' : '';\n\n let removed = 0;\n for (let i = 0; i < binaries.length; i++) {\n const binaryPath = path.join(binDir, binaries[i] + ext);\n if (fs.existsSync(binaryPath)) {\n rmSync(binaryPath, { force: true });\n removed++;\n }\n }\n\n if (removed > 0) {\n console.log(`Removed ${removed} binary(s) from ${binDir}`);\n console.log('');\n console.log('You may also want to remove ~/.nvu/bin from your PATH.');\n } else {\n console.log('No binaries found to remove.');\n }\n\n exit(0);\n}\n"],"names":["teardownCmd","_args","binDir","path","join","storagePath","binaries","ext","process","platform","removed","i","length","binaryPath","fs","existsSync","rmSync","force","console","log","exit"],"mappings":";;;;+BAMA;;;;CAIC,GACD;;;eAAwBA;;;iEAXP;yDACF;8BACQ;2DACN;2BACW;;;;;;AAOb,SAASA,YAAYC,KAAe;IACjD,IAAMC,SAASC,aAAI,CAACC,IAAI,CAACC,wBAAW,EAAE;IAEtC,IAAMC,WAAW;QAAC;QAAQ;QAAO;KAAM;IACvC,IAAMC,MAAMC,QAAQC,QAAQ,KAAK,UAAU,SAAS;IAEpD,IAAIC,UAAU;IACd,IAAK,IAAIC,IAAI,GAAGA,IAAIL,SAASM,MAAM,EAAED,IAAK;QACxC,IAAME,aAAaV,aAAI,CAACC,IAAI,CAACF,QAAQI,QAAQ,CAACK,EAAE,GAAGJ;QACnD,IAAIO,WAAE,CAACC,UAAU,CAACF,aAAa;YAC7BG,IAAAA,sBAAM,EAACH,YAAY;gBAAEI,OAAO;YAAK;YACjCP;QACF;IACF;IAEA,IAAIA,UAAU,GAAG;QACfQ,QAAQC,GAAG,CAAC,AAAC,WAAoCjB,OAA1BQ,SAAQ,oBAAyB,OAAPR;QACjDgB,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;IACd,OAAO;QACLD,QAAQC,GAAG,CAAC;IACd;IAEAC,IAAAA,mBAAI,EAAC;AACP"}
@@ -12,7 +12,7 @@ Object.defineProperty(exports, /**
12
12
  return uninstallCmd;
13
13
  }
14
14
  });
15
- var _exit = /*#__PURE__*/ _interop_require_default(require("exit"));
15
+ var _exitcompat = /*#__PURE__*/ _interop_require_default(require("exit-compat"));
16
16
  var _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
17
17
  var _path = /*#__PURE__*/ _interop_require_default(require("path"));
18
18
  var _compatts = require("../compat.js");
@@ -27,7 +27,7 @@ function uninstallCmd(args) {
27
27
  console.log('Usage: nvu uninstall <version>');
28
28
  console.log('Example: nvu uninstall 20');
29
29
  console.log(' nvu uninstall v20.19.6');
30
- (0, _exit.default)(1);
30
+ (0, _exitcompat.default)(1);
31
31
  return;
32
32
  }
33
33
  var version = args[0].trim();
@@ -39,7 +39,7 @@ function uninstallCmd(args) {
39
39
  console.log('');
40
40
  console.log('Installed versions:');
41
41
  listInstalledVersions(versionsPath);
42
- (0, _exit.default)(1);
42
+ (0, _exitcompat.default)(1);
43
43
  return;
44
44
  }
45
45
  if (matches.length > 1) {
@@ -49,7 +49,7 @@ function uninstallCmd(args) {
49
49
  }
50
50
  console.log('');
51
51
  console.log('Please specify the exact version to uninstall.');
52
- (0, _exit.default)(1);
52
+ (0, _exitcompat.default)(1);
53
53
  return;
54
54
  }
55
55
  var installedVersion = matches[0];
@@ -79,10 +79,10 @@ function uninstallCmd(args) {
79
79
  }
80
80
  } catch (err) {
81
81
  console.error("Failed to remove Node ".concat(installedVersion, ":"), err.message);
82
- (0, _exit.default)(1);
82
+ (0, _exitcompat.default)(1);
83
83
  return;
84
84
  }
85
- (0, _exit.default)(0);
85
+ (0, _exitcompat.default)(0);
86
86
  }
87
87
  /**
88
88
  * Find all installed versions matching the given version string
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/uninstall.ts"],"sourcesContent":["import exit from 'exit';\nimport fs from 'fs';\nimport path from 'path';\nimport { readdirWithTypes, rmSync } from '../compat.ts';\nimport { storagePath } from '../constants.ts';\n\n/**\n * nvu uninstall <version>\n *\n * Remove an installed Node version.\n */\nexport default function uninstallCmd(args: string[]): void {\n if (args.length === 0) {\n console.log('Usage: nvu uninstall <version>');\n console.log('Example: nvu uninstall 20');\n console.log(' nvu uninstall v20.19.6');\n exit(1);\n return;\n }\n\n var version = args[0].trim();\n var versionsPath = path.join(storagePath, 'installed');\n\n // Find all matching installed versions\n var matches = findInstalledVersions(versionsPath, version);\n\n if (matches.length === 0) {\n console.log(`Node ${version} is not installed.`);\n console.log('');\n console.log('Installed versions:');\n listInstalledVersions(versionsPath);\n exit(1);\n return;\n }\n\n if (matches.length > 1) {\n console.log(`Multiple versions match \"${version}\":`);\n for (var i = 0; i < matches.length; i++) {\n console.log(` ${matches[i]}`);\n }\n console.log('');\n console.log('Please specify the exact version to uninstall.');\n exit(1);\n return;\n }\n\n var installedVersion = matches[0];\n var versionPath = path.join(versionsPath, installedVersion);\n\n // Check if this is the current default\n var defaultPath = path.join(storagePath, 'default');\n var isDefault = false;\n if (fs.existsSync(defaultPath)) {\n var defaultVersion = fs.readFileSync(defaultPath, 'utf8').trim();\n var normalizedDefault = defaultVersion.replace(/^v/, '');\n var normalizedInstalled = installedVersion.replace(/^v/, '');\n\n // Check if default matches this version\n if (normalizedInstalled === normalizedDefault || normalizedInstalled.indexOf(`${normalizedDefault}.`) === 0) {\n isDefault = true;\n }\n }\n\n // Remove the version directory\n try {\n rmSync(versionPath);\n console.log(`Removed Node ${installedVersion}`);\n\n if (isDefault) {\n // Clear the default since it's no longer installed\n fs.unlinkSync(defaultPath);\n console.log('');\n console.log('Note: This was your default version. Set a new default with:');\n console.log(' nvu default <version>');\n }\n } catch (err) {\n console.error(`Failed to remove Node ${installedVersion}:`, (err as Error).message);\n exit(1);\n return;\n }\n\n exit(0);\n}\n\n/**\n * Find all installed versions matching the given version string\n */\nfunction findInstalledVersions(versionsPath: string, version: string): string[] {\n if (!fs.existsSync(versionsPath)) {\n return [];\n }\n\n var normalizedVersion = version.replace(/^v/, '');\n var matches: string[] = [];\n\n // Try exact matches first\n var exactMatches = [version, `v${normalizedVersion}`, normalizedVersion];\n for (var i = 0; i < exactMatches.length; i++) {\n var v = exactMatches[i];\n var versionPath = path.join(versionsPath, v);\n if (fs.existsSync(versionPath) && fs.statSync(versionPath).isDirectory()) {\n if (matches.indexOf(v) === -1) {\n matches.push(v);\n }\n }\n }\n\n // If we have an exact match, return just that\n if (matches.length > 0) {\n return matches;\n }\n\n // Try partial match (e.g., \"20\" matches \"v20.19.6\")\n var entries = readdirWithTypes(versionsPath);\n for (var j = 0; j < entries.length; j++) {\n var entry = entries[j];\n if (!entry.isDirectory()) continue;\n var dirVersion = entry.name.replace(/^v/, '');\n if (dirVersion.indexOf(`${normalizedVersion}.`) === 0) {\n matches.push(entry.name);\n }\n }\n\n return matches;\n}\n\n/**\n * List installed versions for user reference\n */\nfunction listInstalledVersions(versionsPath: string): void {\n if (!fs.existsSync(versionsPath)) {\n console.log(' (none)');\n return;\n }\n\n var entries = readdirWithTypes(versionsPath);\n var versions: string[] = [];\n for (var i = 0; i < entries.length; i++) {\n if (entries[i].isDirectory()) {\n versions.push(entries[i].name);\n }\n }\n\n if (versions.length === 0) {\n console.log(' (none)');\n } else {\n for (var j = 0; j < versions.length; j++) {\n console.log(` ${versions[j]}`);\n }\n }\n}\n"],"names":["uninstallCmd","args","length","console","log","exit","version","trim","versionsPath","path","join","storagePath","matches","findInstalledVersions","listInstalledVersions","i","installedVersion","versionPath","defaultPath","isDefault","fs","existsSync","defaultVersion","readFileSync","normalizedDefault","replace","normalizedInstalled","indexOf","rmSync","unlinkSync","err","error","message","normalizedVersion","exactMatches","v","statSync","isDirectory","push","entries","readdirWithTypes","j","entry","dirVersion","name","versions"],"mappings":";;;;+BAMA;;;;CAIC,GACD;;;eAAwBA;;;2DAXP;yDACF;2DACE;wBACwB;2BACb;;;;;;AAOb,SAASA,aAAaC,IAAc;IACjD,IAAIA,KAAKC,MAAM,KAAK,GAAG;QACrBC,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZC,IAAAA,aAAI,EAAC;QACL;IACF;IAEA,IAAIC,UAAUL,IAAI,CAAC,EAAE,CAACM,IAAI;IAC1B,IAAIC,eAAeC,aAAI,CAACC,IAAI,CAACC,wBAAW,EAAE;IAE1C,uCAAuC;IACvC,IAAIC,UAAUC,sBAAsBL,cAAcF;IAElD,IAAIM,QAAQV,MAAM,KAAK,GAAG;QACxBC,QAAQC,GAAG,CAAC,AAAC,QAAe,OAARE,SAAQ;QAC5BH,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZU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ACT;AAEA;;CAEC,GACD,SAASE,sBAAsBN,YAAoB;IACjD,IAAI,CAACY,WAAE,CAACC,UAAU,CAACb,eAAe;QAChCL,QAAQC,GAAG,CAAC;QACZ;IACF;IAEA,IAAImC,UAAUC,IAAAA,0BAAgB,EAAChC;IAC/B,IAAIqC,WAAqB,EAAE;IAC3B,IAAK,IAAI9B,IAAI,GAAGA,IAAIwB,QAAQrC,MAAM,EAAEa,IAAK;QACvC,IAAIwB,OAAO,CAACxB,EAAE,CAACsB,WAAW,IAAI;YAC5BQ,SAASP,IAAI,CAACC,OAAO,CAACxB,EAAE,CAAC6B,IAAI;QAC/B;IACF;IAEA,IAAIC,SAAS3C,MAAM,KAAK,GAAG;QACzBC,QAAQC,GAAG,CAAC;IACd,OAAO;QACL,IAAK,IAAIqC,IAAI,GAAGA,IAAII,SAAS3C,MAAM,EAAEuC,IAAK;YACxCtC,QAAQC,GAAG,CAAC,AAAC,KAAgB,OAAZyC,QAAQ,CAACJ,EAAE;QAC9B;IACF;AACF"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/uninstall.ts"],"sourcesContent":["import exit from 'exit-compat';\nimport fs from 'fs';\nimport path from 'path';\nimport { readdirWithTypes, rmSync } from '../compat.ts';\nimport { storagePath } from '../constants.ts';\n\n/**\n * nvu uninstall <version>\n *\n * Remove an installed Node version.\n */\nexport default function uninstallCmd(args: string[]): void {\n if (args.length === 0) {\n console.log('Usage: nvu uninstall <version>');\n console.log('Example: nvu uninstall 20');\n console.log(' nvu uninstall v20.19.6');\n exit(1);\n return;\n }\n\n var version = args[0].trim();\n var versionsPath = path.join(storagePath, 'installed');\n\n // Find all matching installed versions\n var matches = findInstalledVersions(versionsPath, version);\n\n if (matches.length === 0) {\n console.log(`Node ${version} is not installed.`);\n console.log('');\n console.log('Installed versions:');\n listInstalledVersions(versionsPath);\n exit(1);\n return;\n }\n\n if (matches.length > 1) {\n console.log(`Multiple versions match \"${version}\":`);\n for (var i = 0; i < matches.length; i++) {\n console.log(` ${matches[i]}`);\n }\n console.log('');\n console.log('Please specify the exact version to uninstall.');\n exit(1);\n return;\n }\n\n var installedVersion = matches[0];\n var versionPath = path.join(versionsPath, installedVersion);\n\n // Check if this is the current default\n var defaultPath = path.join(storagePath, 'default');\n var isDefault = false;\n if (fs.existsSync(defaultPath)) {\n var defaultVersion = fs.readFileSync(defaultPath, 'utf8').trim();\n var normalizedDefault = defaultVersion.replace(/^v/, '');\n var normalizedInstalled = installedVersion.replace(/^v/, '');\n\n // Check if default matches this version\n if (normalizedInstalled === normalizedDefault || normalizedInstalled.indexOf(`${normalizedDefault}.`) === 0) {\n isDefault = true;\n }\n }\n\n // Remove the version directory\n try {\n rmSync(versionPath);\n console.log(`Removed Node ${installedVersion}`);\n\n if (isDefault) {\n // Clear the default since it's no longer installed\n fs.unlinkSync(defaultPath);\n console.log('');\n console.log('Note: This was your default version. Set a new default with:');\n console.log(' nvu default <version>');\n }\n } catch (err) {\n console.error(`Failed to remove Node ${installedVersion}:`, (err as Error).message);\n exit(1);\n return;\n }\n\n exit(0);\n}\n\n/**\n * Find all installed versions matching the given version string\n */\nfunction findInstalledVersions(versionsPath: string, version: string): string[] {\n if (!fs.existsSync(versionsPath)) {\n return [];\n }\n\n var normalizedVersion = version.replace(/^v/, '');\n var matches: string[] = [];\n\n // Try exact matches first\n var exactMatches = [version, `v${normalizedVersion}`, normalizedVersion];\n for (var i = 0; i < exactMatches.length; i++) {\n var v = exactMatches[i];\n var versionPath = path.join(versionsPath, v);\n if (fs.existsSync(versionPath) && fs.statSync(versionPath).isDirectory()) {\n if (matches.indexOf(v) === -1) {\n matches.push(v);\n }\n }\n }\n\n // If we have an exact match, return just that\n if (matches.length > 0) {\n return matches;\n }\n\n // Try partial match (e.g., \"20\" matches \"v20.19.6\")\n var entries = readdirWithTypes(versionsPath);\n for (var j = 0; j < entries.length; j++) {\n var entry = entries[j];\n if (!entry.isDirectory()) continue;\n var dirVersion = entry.name.replace(/^v/, '');\n if (dirVersion.indexOf(`${normalizedVersion}.`) === 0) {\n matches.push(entry.name);\n }\n }\n\n return matches;\n}\n\n/**\n * List installed versions for user reference\n */\nfunction listInstalledVersions(versionsPath: string): void {\n if (!fs.existsSync(versionsPath)) {\n console.log(' (none)');\n return;\n }\n\n var entries = readdirWithTypes(versionsPath);\n var versions: string[] = [];\n for (var i = 0; i < entries.length; i++) {\n if (entries[i].isDirectory()) {\n versions.push(entries[i].name);\n }\n }\n\n if (versions.length === 0) {\n console.log(' (none)');\n } else {\n for (var j = 0; j < versions.length; j++) {\n console.log(` ${versions[j]}`);\n }\n }\n}\n"],"names":["uninstallCmd","args","length","console","log","exit","version","trim","versionsPath","path","join","storagePath","matches","findInstalledVersions","listInstalledVersions","i","installedVersion","versionPath","defaultPath","isDefault","fs","existsSync","defaultVersion","readFileSync","normalizedDefault","replace","normalizedInstalled","indexOf","rmSync","unlinkSync","err","error","message","normalizedVersion","exactMatches","v","statSync","isDirectory","push","entries","readdirWithTypes","j","entry","dirVersion","name","versions"],"mappings":";;;;+BAMA;;;;CAIC,GACD;;;eAAwBA;;;iEAXP;yDACF;2DACE;wBACwB;2BACb;;;;;;AAOb,SAASA,aAAaC,IAAc;IACjD,IAAIA,KAAKC,MAAM,KAAK,GAAG;QACrBC,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZC,IAAAA,mBAAI,EAAC;QACL;IACF;IAEA,IAAIC,UAAUL,IAAI,CAAC,EAAE,CAACM,IAAI;IAC1B,IAAIC,eAAeC,aAAI,CAACC,IAAI,CAACC,wBAAW,EAAE;IAE1C,uCAAuC;IACvC,IAAIC,UAAUC,sBAAsBL,cAAcF;IAElD,IAAIM,QAAQV,MAAM,KAAK,GAAG;QACxBC,QAAQC,GAAG,CAAC,AAAC,QAAe,OAARE,SAAQ;QAC5BH,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZU,sBAAsBN;QACtBH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AEC,GACD,SAASE,sBAAsBN,YAAoB;IACjD,IAAI,CAACY,WAAE,CAACC,UAAU,CAACb,eAAe;QAChCL,QAAQC,GAAG,CAAC;QACZ;IACF;IAEA,IAAImC,UAAUC,IAAAA,0BAAgB,EAAChC;IAC/B,IAAIqC,WAAqB,EAAE;IAC3B,IAAK,IAAI9B,IAAI,GAAGA,IAAIwB,QAAQrC,MAAM,EAAEa,IAAK;QACvC,IAAIwB,OAAO,CAACxB,EAAE,CAACsB,WAAW,IAAI;YAC5BQ,SAASP,IAAI,CAACC,OAAO,CAACxB,EAAE,CAAC6B,IAAI;QAC/B;IACF;IAEA,IAAIC,SAAS3C,MAAM,KAAK,GAAG;QACzBC,QAAQC,GAAG,CAAC;IACd,OAAO;QACL,IAAK,IAAIqC,IAAI,GAAGA,IAAII,SAAS3C,MAAM,EAAEuC,IAAK;YACxCtC,QAAQC,GAAG,CAAC,AAAC,KAAgB,OAAZyC,QAAQ,CAACJ,EAAE;QAC9B;IACF;AACF"}
@@ -13,7 +13,7 @@ Object.defineProperty(exports, /**
13
13
  return whichCmd;
14
14
  }
15
15
  });
16
- var _exit = /*#__PURE__*/ _interop_require_default(require("exit"));
16
+ var _exitcompat = /*#__PURE__*/ _interop_require_default(require("exit-compat"));
17
17
  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");
@@ -32,7 +32,7 @@ function whichCmd(_args) {
32
32
  console.log('To configure a version:');
33
33
  console.log(' nvu local <version> - Set version for this project');
34
34
  console.log(' nvu default <version> - Set global default');
35
- (0, _exit.default)(1);
35
+ (0, _exitcompat.default)(1);
36
36
  return;
37
37
  }
38
38
  // Check if the version is installed
@@ -61,7 +61,7 @@ function whichCmd(_args) {
61
61
  } else {
62
62
  console.log("Status: Not installed (run: nvu install ".concat(version, ")"));
63
63
  }
64
- (0, _exit.default)(0);
64
+ (0, _exitcompat.default)(0);
65
65
  }
66
66
  /**
67
67
  * Resolve version from config files (mirrors nvu binary logic)
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/which.ts"],"sourcesContent":["import exit from 'exit';\nimport fs from 'fs';\nimport path from 'path';\nimport { storagePath } from '../constants.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 // Check if the version is installed\n const versionsPath = path.join(storagePath, 'installed');\n const versionPath = path.join(versionsPath, version);\n const versionPathWithV = path.join(versionsPath, `v${version}`);\n const versionPathWithoutV = path.join(versionsPath, version.replace(/^v/, ''));\n\n let actualVersionPath = '';\n if (fs.existsSync(versionPath)) {\n actualVersionPath = versionPath;\n } else if (fs.existsSync(versionPathWithV)) {\n actualVersionPath = versionPathWithV;\n } else if (fs.existsSync(versionPathWithoutV)) {\n actualVersionPath = versionPathWithoutV;\n }\n\n console.log(`Version: ${version}`);\n console.log(`Source: ${getVersionSource(cwd)}`);\n\n if (actualVersionPath) {\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","versionPath","versionPathWithV","versionPathWithoutV","replace","actualVersionPath","fs","existsSync","getVersionSource","nodePath","dir","nvurcPath","readFileSync","trim","nvmrcPath","parent","dirname","defaultPath"],"mappings":";;;;+BAKA;;;;;CAKC,GACD;;;eAAwBA;;;2DAXP;yDACF;2DACE;2BACW;;;;;;AAQb,SAASA,SAASC,KAAe;IAC9C,IAAMC,MAAMC,QAAQD,GAAG;IAEvB,yDAAyD;IACzD,IAAME,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;QACZC,IAAAA,aAAI,EAAC;QACL;IACF;IAEA,oCAAoC;IACpC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aAAI,CAACC,IAAI,CAACW,KAAK;QACjC,IAAIJ,WAAE,CAACC,UAAU,CAACO,YAAY;YAC5B,OAAOR,WAAE,CAACM,YAAY,CAACE,WAAW,QAAQD,IAAI;QAChD;QAEA,iBAAiB;QACjB,IAAME,SAASjB,aAAI,CAACkB,OAAO,CAACN;QAC5B,IAAIK,WAAWL,KAAK;QACpBA,MAAMK;IACR;IAEA,uBAAuB;IACvB,IAAME,cAAcnB,aAAI,CAACC,IAAI,CAACC,wBAAW,EAAE;IAC3C,IAAIM,WAAE,CAACC,UAAU,CAACU,cAAc;QAC9B,OAAOX,WAAE,CAACM,YAAY,CAACK,aAAa,QAAQJ,IAAI;IAClD;IAEA,OAAO;AACT;AAEA;;CAEC,GACD,SAASL,iBAAiBlB,GAAW;IACnC,IAAIoB,MAAMpB;IACV,MAAO,KAAM;QACX,IAAMqB,YAAYb,aAAI,CAACC,IAAI,CAACW,KAAK;QACjC,IAAIJ,WAAE,CAACC,UAAU,CAACI,YAAY;YAC5B,OAAOA;QACT;QAEA,IAAMG,YAAYhB,aAAI,CAACC,IAAI,CAACW,KAAK;QACjC,IAAIJ,WAAE,CAACC,UAAU,CAACO,YAAY;YAC5B,OAAOA;QACT;QAEA,IAAMC,SAASjB,aAAI,CAACkB,OAAO,CAACN;QAC5B,IAAIK,WAAWL,KAAK;QACpBA,MAAMK;IACR;IAEA,IAAME,cAAcnB,aAAI,CAACC,IAAI,CAACC,wBAAW,EAAE;IAC3C,IAAIM,WAAE,CAACC,UAAU,CAACU,cAAc;QAC9B,OAAO,AAAC,GAAc,OAAZA,aAAY;IACxB;IAEA,OAAO;AACT"}
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';\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 // Check if the version is installed\n const versionsPath = path.join(storagePath, 'installed');\n const versionPath = path.join(versionsPath, version);\n const versionPathWithV = path.join(versionsPath, `v${version}`);\n const versionPathWithoutV = path.join(versionsPath, version.replace(/^v/, ''));\n\n let actualVersionPath = '';\n if (fs.existsSync(versionPath)) {\n actualVersionPath = versionPath;\n } else if (fs.existsSync(versionPathWithV)) {\n actualVersionPath = versionPathWithV;\n } else if (fs.existsSync(versionPathWithoutV)) {\n actualVersionPath = versionPathWithoutV;\n }\n\n console.log(`Version: ${version}`);\n console.log(`Source: ${getVersionSource(cwd)}`);\n\n if (actualVersionPath) {\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","versionPath","versionPathWithV","versionPathWithoutV","replace","actualVersionPath","fs","existsSync","getVersionSource","nodePath","dir","nvurcPath","readFileSync","trim","nvmrcPath","parent","dirname","defaultPath"],"mappings":";;;;+BAKA;;;;;CAKC,GACD;;;eAAwBA;;;iEAXP;yDACF;2DACE;2BACW;;;;;;AAQb,SAASA,SAASC,KAAe;IAC9C,IAAMC,MAAMC,QAAQD,GAAG;IAEvB,yDAAyD;IACzD,IAAME,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;QACZC,IAAAA,mBAAI,EAAC;QACL;IACF;IAEA,oCAAoC;IACpC,IAAMC,eAAeC,aAAI,CAACC,IAAI,CAACC,wBAAW,EAAE;IAC5C,IAAMC,cAAcH,aAAI,CAACC,IAAI,CAACF,cAAcL;IAC5C,IAAMU,mBAAmBJ,aAAI,CAACC,IAAI,CAACF,cAAc,AAAC,IAAW,OAARL;IACrD,IAAMW,sBAAsBL,aAAI,CAACC,IAAI,CAACF,cAAcL,QAAQY,OAAO,CAAC,MAAM;IAE1E,IAAI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,cAAcnB,aAAI,CAACC,IAAI,CAACC,wBAAW,EAAE;IAC3C,IAAIM,WAAE,CAACC,UAAU,CAACU,cAAc;QAC9B,OAAOX,WAAE,CAACM,YAAY,CAACK,aAAa,QAAQJ,IAAI;IAClD;IAEA,OAAO;AACT;AAEA;;CAEC,GACD,SAASL,iBAAiBlB,GAAW;IACnC,IAAIoB,MAAMpB;IACV,MAAO,KAAM;QACX,IAAMqB,YAAYb,aAAI,CAACC,IAAI,CAACW,KAAK;QACjC,IAAIJ,WAAE,CAACC,UAAU,CAACI,YAAY;YAC5B,OAAOA;QACT;QAEA,IAAMG,YAAYhB,aAAI,CAACC,IAAI,CAACW,KAAK;QACjC,IAAIJ,WAAE,CAACC,UAAU,CAACO,YAAY;YAC5B,OAAOA;QACT;QAEA,IAAMC,SAASjB,aAAI,CAACkB,OAAO,CAACN;QAC5B,IAAIK,WAAWL,KAAK;QACpBA,MAAMK;IACR;IAEA,IAAME,cAAcnB,aAAI,CAACC,IAAI,CAACC,wBAAW,EAAE;IAC3C,IAAIM,WAAE,CAACC,UAAU,CAACU,cAAc;QAC9B,OAAO,AAAC,GAAc,OAAZA,aAAY;IACxB;IAEA,OAAO;AACT"}
package/dist/esm/cli.js CHANGED
@@ -1,4 +1,4 @@
1
- import exit from 'exit';
1
+ import exit from 'exit-compat';
2
2
  import fs from 'fs';
3
3
  import getopts from 'getopts-compat';
4
4
  import path from 'path';
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/cli.ts"],"sourcesContent":["import exit from 'exit';\nimport fs from 'fs';\nimport getopts from 'getopts-compat';\nimport path from 'path';\nimport { createSession, figures, formatArguments } from 'spawn-term';\nimport url from 'url';\nimport { isCommand, runCommand } from './commands/index.ts';\nimport run from './index.ts';\nimport type { UseError, UseOptions, UseResult } from './types.ts';\n\nconst __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url));\n\nconst ERROR_CODE = 13;\n\nfunction getVersion(): string {\n const packagePath = path.join(__dirname, '..', '..', 'package.json');\n const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf8'));\n return packageJson.version;\n}\n\nfunction printHelp(name: string): void {\n const version = getVersion();\n console.log(`${name} v${version}`);\n console.log('');\n console.log(`Usage: ${name} [options] <version> <command> [args...]`);\n console.log(` ${name} <subcommand> [args...]`);\n console.log('');\n console.log('Run commands with specific Node.js versions');\n console.log('');\n console.log('Subcommands:');\n console.log(' default [version] Set or display the global default Node version');\n console.log(' local [version] Set or display the local Node version (.nvmrc)');\n console.log(' install <version> Download and install a Node version');\n console.log(' uninstall <version> Remove an installed Node version');\n console.log(' list List installed Node versions');\n console.log(' which Show which Node version would be used');\n console.log(' setup Install/reinstall binaries to ~/.nvu/bin');\n console.log(' teardown Remove binaries from ~/.nvu/bin');\n console.log('');\n console.log('Options:');\n console.log(' -v, --version Print version number');\n console.log(' -h, --help Print this help message');\n console.log(' -r, --range Range type (major, minor, patch) with filters (lts, even, odd)');\n console.log(' Default: major,even');\n console.log(' -d, --desc Sort versions in descending order');\n console.log(' -e, --expanded Use expanded version format');\n console.log(' -s, --streaming Enable streaming output');\n console.log(' --silent Suppress logging');\n console.log('');\n console.log('Examples:');\n console.log(` ${name} 22 node --version Run with Node 22`);\n console.log(` ${name} 22,20,18 npm test Run with multiple versions`);\n console.log(` ${name} engines node --version Use version from package.json`);\n console.log(` ${name} default 20 Set global default to Node 20`);\n console.log(` ${name} local 18 Create .nvmrc with Node 18`);\n}\n\nexport default (argv: string[], name: string): undefined => {\n const options = getopts(argv, {\n alias: { range: 'r', desc: 'd', expanded: 'e', streaming: 's', silent: 'si', version: 'v', help: 'h' },\n default: { range: 'major,even', interactive: true },\n boolean: ['silent', 'desc', 'expanded', 'streaming', 'interactive', 'version', 'help'],\n stopEarly: true,\n });\n\n if (options.version) {\n console.log(getVersion());\n exit(0);\n return;\n }\n\n if (options.help) {\n printHelp(name);\n exit(0);\n return;\n }\n\n // Check if first argument is a subcommand\n const args = options._;\n if (args.length > 0 && isCommand(args[0])) {\n runCommand(args[0], args.slice(1));\n return;\n }\n\n // define.option('-r, --range [range]', 'range type of major, minor, or patch with filters of lts, even, odd for version string expressions', 'major,even');\n // define.option('-s, --silent', 'suppress logging', false);\n options.sort = options.desc ? -1 : 1;\n\n if (args.length === 0) {\n console.log(`Missing version expression. Example usage: ${name} version command arg1 arg2`);\n exit(ERROR_CODE);\n return;\n }\n if (args.length === 1) {\n console.log(`Missing command. Example usage: ${name} version command arg1 arg2`);\n exit(ERROR_CODE);\n return;\n }\n\n options.stdio = 'inherit'; // pass through stdio\n run(args[0], args[1], args.slice(2), options as unknown as UseOptions, (err: UseError, results: UseResult[]): undefined => {\n if (err && !err.results) {\n console.log(err.message);\n exit(ERROR_CODE);\n return;\n }\n if (err) results = err.results;\n const errors = results.filter((result) => !!result.error);\n\n if (!options.silent) {\n if (!createSession) {\n console.log('\\n======================');\n results.forEach((res) => {\n console.log(`${res.error ? figures.cross : figures.tick} ${res.version}${res.error ? ` Error: ${res.error.message}` : ''}`);\n });\n console.log('\\n----------------------');\n console.log(`${name} ${formatArguments(args).join(' ')}`);\n console.log(`${figures.tick} ${results.length - errors.length} succeeded`);\n if (errors.length) console.log(`${figures.cross} ${errors.length} failed`);\n }\n }\n exit(err || errors.length ? ERROR_CODE : 0);\n });\n};\n"],"names":["exit","fs","getopts","path","createSession","figures","formatArguments","url","isCommand","runCommand","run","__dirname","dirname","__filename","fileURLToPath","ERROR_CODE","getVersion","packagePath","join","packageJson","JSON","parse","readFileSync","version","printHelp","name","console","log","argv","options","alias","range","desc","expanded","streaming","silent","help","default","interactive","boolean","stopEarly","args","_","length","slice","sort","stdio","err","results","message","errors","filter","result","error","forEach","res","cross","tick"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AACxB,OAAOC,QAAQ,KAAK;AACpB,OAAOC,aAAa,iBAAiB;AACrC,OAAOC,UAAU,OAAO;AACxB,SAASC,aAAa,EAAEC,OAAO,EAAE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,QAAQmD,KAAK,CAAC,CAAC,EAAEN,OAAOP,MAAM,CAAC,OAAO,CAAC;YAC3E;QACF;QACA3C,KAAK+C,OAAOG,OAAOP,MAAM,GAAG5B,aAAa;IAC3C;AACF,CAAA,EAAE"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/cli.ts"],"sourcesContent":["import exit from 'exit-compat';\nimport fs from 'fs';\nimport getopts from 'getopts-compat';\nimport path from 'path';\nimport { createSession, figures, formatArguments } from 'spawn-term';\nimport url from 'url';\nimport { isCommand, runCommand } from './commands/index.ts';\nimport run from './index.ts';\nimport type { UseError, UseOptions, UseResult } from './types.ts';\n\nconst __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url));\n\nconst ERROR_CODE = 13;\n\nfunction getVersion(): string {\n const packagePath = path.join(__dirname, '..', '..', 'package.json');\n const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf8'));\n return packageJson.version;\n}\n\nfunction printHelp(name: string): void {\n const version = getVersion();\n console.log(`${name} v${version}`);\n console.log('');\n console.log(`Usage: ${name} [options] <version> <command> [args...]`);\n console.log(` ${name} <subcommand> [args...]`);\n console.log('');\n console.log('Run commands with specific Node.js versions');\n console.log('');\n console.log('Subcommands:');\n console.log(' default [version] Set or display the global default Node version');\n console.log(' local [version] Set or display the local Node version (.nvmrc)');\n console.log(' install <version> Download and install a Node version');\n console.log(' uninstall <version> Remove an installed Node version');\n console.log(' list List installed Node versions');\n console.log(' which Show which Node version would be used');\n console.log(' setup Install/reinstall binaries to ~/.nvu/bin');\n console.log(' teardown Remove binaries from ~/.nvu/bin');\n console.log('');\n console.log('Options:');\n console.log(' -v, --version Print version number');\n console.log(' -h, --help Print this help message');\n console.log(' -r, --range Range type (major, minor, patch) with filters (lts, even, odd)');\n console.log(' Default: major,even');\n console.log(' -d, --desc Sort versions in descending order');\n console.log(' -e, --expanded Use expanded version format');\n console.log(' -s, --streaming Enable streaming output');\n console.log(' --silent Suppress logging');\n console.log('');\n console.log('Examples:');\n console.log(` ${name} 22 node --version Run with Node 22`);\n console.log(` ${name} 22,20,18 npm test Run with multiple versions`);\n console.log(` ${name} engines node --version Use version from package.json`);\n console.log(` ${name} default 20 Set global default to Node 20`);\n console.log(` ${name} local 18 Create .nvmrc with Node 18`);\n}\n\nexport default (argv: string[], name: string): undefined => {\n const options = getopts(argv, {\n alias: { range: 'r', desc: 'd', expanded: 'e', streaming: 's', silent: 'si', version: 'v', help: 'h' },\n default: { range: 'major,even', interactive: true },\n boolean: ['silent', 'desc', 'expanded', 'streaming', 'interactive', 'version', 'help'],\n stopEarly: true,\n });\n\n if (options.version) {\n console.log(getVersion());\n exit(0);\n return;\n }\n\n if (options.help) {\n printHelp(name);\n exit(0);\n return;\n }\n\n // Check if first argument is a subcommand\n const args = options._;\n if (args.length > 0 && isCommand(args[0])) {\n runCommand(args[0], args.slice(1));\n return;\n }\n\n // define.option('-r, --range [range]', 'range type of major, minor, or patch with filters of lts, even, odd for version string expressions', 'major,even');\n // define.option('-s, --silent', 'suppress logging', false);\n options.sort = options.desc ? -1 : 1;\n\n if (args.length === 0) {\n console.log(`Missing version expression. Example usage: ${name} version command arg1 arg2`);\n exit(ERROR_CODE);\n return;\n }\n if (args.length === 1) {\n console.log(`Missing command. Example usage: ${name} version command arg1 arg2`);\n exit(ERROR_CODE);\n return;\n }\n\n options.stdio = 'inherit'; // pass through stdio\n run(args[0], args[1], args.slice(2), options as unknown as UseOptions, (err: UseError, results: UseResult[]): undefined => {\n if (err && !err.results) {\n console.log(err.message);\n exit(ERROR_CODE);\n return;\n }\n if (err) results = err.results;\n const errors = results.filter((result) => !!result.error);\n\n if (!options.silent) {\n if (!createSession) {\n console.log('\\n======================');\n results.forEach((res) => {\n console.log(`${res.error ? figures.cross : figures.tick} ${res.version}${res.error ? ` Error: ${res.error.message}` : ''}`);\n });\n console.log('\\n----------------------');\n console.log(`${name} ${formatArguments(args).join(' ')}`);\n console.log(`${figures.tick} ${results.length - errors.length} succeeded`);\n if (errors.length) console.log(`${figures.cross} ${errors.length} failed`);\n }\n }\n exit(err || errors.length ? ERROR_CODE : 0);\n });\n};\n"],"names":["exit","fs","getopts","path","createSession","figures","formatArguments","url","isCommand","runCommand","run","__dirname","dirname","__filename","fileURLToPath","ERROR_CODE","getVersion","packagePath","join","packageJson","JSON","parse","readFileSync","version","printHelp","name","console","log","argv","options","alias","range","desc","expanded","streaming","silent","help","default","interactive","boolean","stopEarly","args","_","length","slice","sort","stdio","err","results","message","errors","filter","result","error","forEach","res","cross","tick"],"mappings":"AAAA,OAAOA,UAAU,cAAc;AAC/B,OAAOC,QAAQ,KAAK;AACpB,OAAOC,aAAa,iBAAiB;AACrC,OAAOC,UAAU,OAAO;AACxB,SAASC,aAAa,EAAEC,OAAO,EAAEC,eAAe,QAAQ,aAAa;AACrE,OAAOC,SAAS,MAAM;AACtB,SAASC,SAAS,EAAEC,UAAU,QAAQ,sBAAsB;AAC5D,OAAOC,SAAS,aAAa;AAG7B,MAAMC,YAAYR,KAAKS,OAAO,CAAC,OAAOC,eAAe,cAAcA,aAAaN,IAAIO,aAAa,CAAC,YAAYP,GAAG;AAEjH,MAAMQ,aAAa;AAEnB,SAASC;IACP,MAAMC,cAAcd,KAAKe,IAAI,CAACP,WAAW,MAAM,MAAM;IACrD,MAAMQ,cAAcC,KAAKC,KAAK,CAACpB,GAAGqB,YAAY,CAACL,aAAa;IAC5D,OAAOE,YAAYI,OAAO;AAC5B;AAEA,SAASC,UAAUC,IAAY;IAC7B,MAAMF,UAAUP;IAChBU,QAAQC,GAAG,CAAC,GAAGF,KAAK,EAAE,EAAEF,SAAS;IACjCG,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC,CAAC,OAAO,EAAEF,KAAK,wCAAwC,CAAC;IACpEC,QAAQC,GAAG,CAAC,CAAC,OAAO,EAAEF,KAAK,uBAAuB,CAAC;IACnDC,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC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G4B,IAAIF,KAAK,GAAGhD,QAAQmD,KAAK,GAAGnD,QAAQoD,IAAI,CAAC,CAAC,EAAEF,IAAIhC,OAAO,GAAGgC,IAAIF,KAAK,GAAG,CAAC,QAAQ,EAAEE,IAAIF,KAAK,CAACJ,OAAO,EAAE,GAAG,IAAI;gBAC5H;gBACAvB,QAAQC,GAAG,CAAC;gBACZD,QAAQC,GAAG,CAAC,GAAGF,KAAK,CAAC,EAAEnB,gBAAgBmC,MAAMvB,IAAI,CAAC,MAAM;gBACxDQ,QAAQC,GAAG,CAAC,GAAGtB,QAAQoD,IAAI,CAAC,CAAC,EAAET,QAAQL,MAAM,GAAGO,OAAOP,MAAM,CAAC,UAAU,CAAC;gBACzE,IAAIO,OAAOP,MAAM,EAAEjB,QAAQC,GAAG,CAAC,GAAGtB,QAAQmD,KAAK,CAAC,CAAC,EAAEN,OAAOP,MAAM,CAAC,OAAO,CAAC;YAC3E;QACF;QACA3C,KAAK+C,OAAOG,OAAOP,MAAM,GAAG5B,aAAa;IAC3C;AACF,CAAA,EAAE"}
@@ -1,4 +1,4 @@
1
- import exit from 'exit';
1
+ import exit from 'exit-compat';
2
2
  import fs from 'fs';
3
3
  import path from 'path';
4
4
  import { mkdirpSync } from '../compat.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/default.ts"],"sourcesContent":["import exit from 'exit';\nimport fs from 'fs';\nimport path from 'path';\nimport { mkdirpSync } from '../compat.ts';\nimport { storagePath } from '../constants.ts';\n\n/**\n * nvu default [version]\n *\n * Set or display the global default Node version.\n * This is used when no .nvmrc or .nvurc is found in the project.\n */\nexport default function defaultCmd(args: string[]): void {\n var defaultFilePath = path.join(storagePath, 'default');\n\n // If no version provided, display current default\n if (args.length === 0) {\n if (fs.existsSync(defaultFilePath)) {\n var currentVersion = fs.readFileSync(defaultFilePath, 'utf8').trim();\n console.log(`Current default: ${currentVersion}`);\n } else {\n console.log('No default version set.');\n console.log('Usage: nvu default <version>');\n }\n exit(0);\n return;\n }\n\n var version = args[0].trim();\n\n // Validate version format (basic check, indexOf for Node 0.8+ compat)\n if (!version || version.indexOf('-') === 0) {\n console.log('Usage: nvu default <version>');\n console.log('Example: nvu default 20');\n exit(1);\n return;\n }\n\n // Ensure storage directory exists\n if (!fs.existsSync(storagePath)) {\n mkdirpSync(storagePath);\n }\n\n // Write the default version\n fs.writeFileSync(defaultFilePath, `${version}\\n`, 'utf8');\n console.log(`Default Node version set to: ${version}`);\n exit(0);\n}\n"],"names":["exit","fs","path","mkdirpSync","storagePath","defaultCmd","args","defaultFilePath","join","length","existsSync","currentVersion","readFileSync","trim","console","log","version","indexOf","writeFileSync"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AACxB,OAAOC,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AACxB,SAASC,UAAU,QAAQ,eAAe;AAC1C,SAASC,WAAW,QAAQ,kBAAkB;AAE9C;;;;;CAKC,GACD,eAAe,SAASC,WAAWC,IAAc;IAC/C,IAAIC,kBAAkBL,KAAKM,IAAI,CAACJ,aAAa;IAE7C,kDAAkD;IAClD,IAAIE,KAAKG,MAAM,KAAK,GAAG;QACrB,IAAIR,GAAGS,UAAU,CAACH,kBAAkB;YAClC,IAAII,iBAAiBV,GAAGW,YAAY,CAACL,iBAAiB,QAAQM,IAAI;YAClEC,QAAQC,GAAG,CAAC,CAAC,iBAAiB,EAAEJ,gBAAgB;QAClD,OAAO;YACLG,QAAQC,GAAG,CAAC;YACZD,QAAQC,GAAG,CAAC;QACd;QACAf,KAAK;QACL;IACF;IAEA,IAAIgB,UAAUV,IAAI,CAAC,EAAE,CAACO,IAAI;IAE1B,sEAAsE;IACtE,IAAI,CAACG,WAAWA,QAAQC,OAAO,CAAC,SAAS,GAAG;QAC1CH,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZf,KAAK;QACL;IACF;IAEA,kCAAkC;IAClC,IAAI,CAACC,GAAGS,UAAU,CAACN,cAAc;QAC/BD,WAAWC;IACb;IAEA,4BAA4B;IAC5BH,GAAGiB,aAAa,CAACX,iBAAiB,GAAGS,QAAQ,EAAE,CAAC,EAAE;IAClDF,QAAQC,GAAG,CAAC,CAAC,6BAA6B,EAAEC,SAAS;IACrDhB,KAAK;AACP"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/default.ts"],"sourcesContent":["import exit from 'exit-compat';\nimport fs from 'fs';\nimport path from 'path';\nimport { mkdirpSync } from '../compat.ts';\nimport { storagePath } from '../constants.ts';\n\n/**\n * nvu default [version]\n *\n * Set or display the global default Node version.\n * This is used when no .nvmrc or .nvurc is found in the project.\n */\nexport default function defaultCmd(args: string[]): void {\n var defaultFilePath = path.join(storagePath, 'default');\n\n // If no version provided, display current default\n if (args.length === 0) {\n if (fs.existsSync(defaultFilePath)) {\n var currentVersion = fs.readFileSync(defaultFilePath, 'utf8').trim();\n console.log(`Current default: ${currentVersion}`);\n } else {\n console.log('No default version set.');\n console.log('Usage: nvu default <version>');\n }\n exit(0);\n return;\n }\n\n var version = args[0].trim();\n\n // Validate version format (basic check, indexOf for Node 0.8+ compat)\n if (!version || version.indexOf('-') === 0) {\n console.log('Usage: nvu default <version>');\n console.log('Example: nvu default 20');\n exit(1);\n return;\n }\n\n // Ensure storage directory exists\n if (!fs.existsSync(storagePath)) {\n mkdirpSync(storagePath);\n }\n\n // Write the default version\n fs.writeFileSync(defaultFilePath, `${version}\\n`, 'utf8');\n console.log(`Default Node version set to: ${version}`);\n exit(0);\n}\n"],"names":["exit","fs","path","mkdirpSync","storagePath","defaultCmd","args","defaultFilePath","join","length","existsSync","currentVersion","readFileSync","trim","console","log","version","indexOf","writeFileSync"],"mappings":"AAAA,OAAOA,UAAU,cAAc;AAC/B,OAAOC,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AACxB,SAASC,UAAU,QAAQ,eAAe;AAC1C,SAASC,WAAW,QAAQ,kBAAkB;AAE9C;;;;;CAKC,GACD,eAAe,SAASC,WAAWC,IAAc;IAC/C,IAAIC,kBAAkBL,KAAKM,IAAI,CAACJ,aAAa;IAE7C,kDAAkD;IAClD,IAAIE,KAAKG,MAAM,KAAK,GAAG;QACrB,IAAIR,GAAGS,UAAU,CAACH,kBAAkB;YAClC,IAAII,iBAAiBV,GAAGW,YAAY,CAACL,iBAAiB,QAAQM,IAAI;YAClEC,QAAQC,GAAG,CAAC,CAAC,iBAAiB,EAAEJ,gBAAgB;QAClD,OAAO;YACLG,QAAQC,GAAG,CAAC;YACZD,QAAQC,GAAG,CAAC;QACd;QACAf,KAAK;QACL;IACF;IAEA,IAAIgB,UAAUV,IAAI,CAAC,EAAE,CAACO,IAAI;IAE1B,sEAAsE;IACtE,IAAI,CAACG,WAAWA,QAAQC,OAAO,CAAC,SAAS,GAAG;QAC1CH,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZf,KAAK;QACL;IACF;IAEA,kCAAkC;IAClC,IAAI,CAACC,GAAGS,UAAU,CAACN,cAAc;QAC/BD,WAAWC;IACb;IAEA,4BAA4B;IAC5BH,GAAGiB,aAAa,CAACX,iBAAiB,GAAGS,QAAQ,EAAE,CAAC,EAAE;IAClDF,QAAQC,GAAG,CAAC,CAAC,6BAA6B,EAAEC,SAAS;IACrDhB,KAAK;AACP"}
@@ -1,4 +1,4 @@
1
- import exit from 'exit';
1
+ import exit from 'exit-compat';
2
2
  import path from 'path';
3
3
  import { storagePath } from '../constants.js';
4
4
  import loadNodeVersionInstall from '../lib/loadNodeVersionInstall.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/install.ts"],"sourcesContent":["import exit from 'exit';\nimport path from 'path';\nimport { storagePath } from '../constants.ts';\nimport loadNodeVersionInstall from '../lib/loadNodeVersionInstall.ts';\n\n/**\n * nvu install <version>\n *\n * Download and install a specific Node version.\n */\nexport default function installCmd(args: string[]): void {\n if (args.length === 0) {\n console.log('Usage: nvu install <version>');\n console.log('Example: nvu install 20');\n console.log(' nvu install 20.10.0');\n console.log(' nvu install lts');\n exit(1);\n return;\n }\n\n const version = args[0].trim();\n\n // Validate version format (basic check, indexOf for Node 0.8+ compat)\n if (!version || version.indexOf('-') === 0) {\n console.log('Usage: nvu install <version>');\n exit(1);\n return;\n }\n\n console.log(`Installing Node ${version}...`);\n\n // Load node-version-install dynamically\n loadNodeVersionInstall((err, nodeVersionInstall) => {\n if (err || !nodeVersionInstall) {\n console.error('Failed to load node-version-install:', err?.message || 'Module not available');\n console.error('Make sure node-version-install is installed: npm install node-version-install');\n exit(1);\n return;\n }\n\n const versionsPath = path.join(storagePath, 'installed');\n\n nodeVersionInstall(\n version,\n {\n installPath: versionsPath,\n },\n (installErr?: Error, results?: { version: string; installPath: string }[]) => {\n if (installErr) {\n console.error(`Failed to install Node ${version}:`, installErr.message);\n exit(1);\n return;\n }\n\n if (results && results.length > 0) {\n const result = results[0];\n console.log(`Successfully installed Node ${result.version}`);\n console.log(`Location: ${result.installPath}`);\n } else {\n console.log(`Node ${version} installed successfully.`);\n }\n exit(0);\n }\n );\n });\n}\n"],"names":["exit","path","storagePath","loadNodeVersionInstall","installCmd","args","length","console","log","version","trim","indexOf","err","nodeVersionInstall","error","message","versionsPath","join","installPath","installErr","results","result"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AACxB,OAAOC,UAAU,OAAO;AACxB,SAASC,WAAW,QAAQ,kBAAkB;AAC9C,OAAOC,4BAA4B,mCAAmC;AAEtE;;;;CAIC,GACD,eAAe,SAASC,WAAWC,IAAc;IAC/C,IAAIA,KAAKC,MAAM,KAAK,GAAG;QACrBC,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZR,KAAK;QACL;IACF;IAEA,MAAMS,UAAUJ,IAAI,CAAC,EAAE,CAACK,IAAI;IAE5B,sEAAsE;IACtE,IAAI,CAACD,WAAWA,QAAQE,OAAO,CAAC,SAAS,GAAG;QAC1CJ,QAAQC,GAAG,CAAC;QACZR,KAAK;QACL;IACF;IAEAO,QAAQC,GAAG,CAAC,CAAC,gBAAgB,EAAEC,QAAQ,GAAG,CAAC;IAE3C,wCAAwC;IACxCN,uBAAuB,CAACS,KAAKC;QAC3B,IAAID,OAAO,CAACC,oBAAoB;YAC9BN,QAAQO,KAAK,CAAC,wCAAwCF,CAAAA,gBAAAA,0BAAAA,IAAKG,OAAO,KAAI;YACtER,QAAQO,KAAK,CAAC;YACdd,KAAK;YACL;QACF;QAEA,MAAMgB,eAAef,KAAKgB,IAAI,CAACf,aAAa;QAE5CW,mBACEJ,SACA;YACES,aAAaF;QACf,GACA,CAACG,YAAoBC;YACnB,IAAID,YAAY;gBACdZ,QAAQO,KAAK,CAAC,CAAC,uBAAuB,EAAEL,QAAQ,CAAC,CAAC,EAAEU,WAAWJ,OAAO;gBACtEf,KAAK;gBACL;YACF;YAEA,IAAIoB,WAAWA,QAAQd,MAAM,GAAG,GAAG;gBACjC,MAAMe,SAASD,OAAO,CAAC,EAAE;gBACzBb,QAAQC,GAAG,CAAC,CAAC,4BAA4B,EAAEa,OAAOZ,OAAO,EAAE;gBAC3DF,QAAQC,GAAG,CAAC,CAAC,UAAU,EAAEa,OAAOH,WAAW,EAAE;YAC/C,OAAO;gBACLX,QAAQC,GAAG,CAAC,CAAC,KAAK,EAAEC,QAAQ,wBAAwB,CAAC;YACvD;YACAT,KAAK;QACP;IAEJ;AACF"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/install.ts"],"sourcesContent":["import exit from 'exit-compat';\nimport path from 'path';\nimport { storagePath } from '../constants.ts';\nimport loadNodeVersionInstall from '../lib/loadNodeVersionInstall.ts';\n\n/**\n * nvu install <version>\n *\n * Download and install a specific Node version.\n */\nexport default function installCmd(args: string[]): void {\n if (args.length === 0) {\n console.log('Usage: nvu install <version>');\n console.log('Example: nvu install 20');\n console.log(' nvu install 20.10.0');\n console.log(' nvu install lts');\n exit(1);\n return;\n }\n\n const version = args[0].trim();\n\n // Validate version format (basic check, indexOf for Node 0.8+ compat)\n if (!version || version.indexOf('-') === 0) {\n console.log('Usage: nvu install <version>');\n exit(1);\n return;\n }\n\n console.log(`Installing Node ${version}...`);\n\n // Load node-version-install dynamically\n loadNodeVersionInstall((err, nodeVersionInstall) => {\n if (err || !nodeVersionInstall) {\n console.error('Failed to load node-version-install:', err?.message || 'Module not available');\n console.error('Make sure node-version-install is installed: npm install node-version-install');\n exit(1);\n return;\n }\n\n const versionsPath = path.join(storagePath, 'installed');\n\n nodeVersionInstall(\n version,\n {\n installPath: versionsPath,\n },\n (installErr?: Error, results?: { version: string; installPath: string }[]) => {\n if (installErr) {\n console.error(`Failed to install Node ${version}:`, installErr.message);\n exit(1);\n return;\n }\n\n if (results && results.length > 0) {\n const result = results[0];\n console.log(`Successfully installed Node ${result.version}`);\n console.log(`Location: ${result.installPath}`);\n } else {\n console.log(`Node ${version} installed successfully.`);\n }\n exit(0);\n }\n );\n });\n}\n"],"names":["exit","path","storagePath","loadNodeVersionInstall","installCmd","args","length","console","log","version","trim","indexOf","err","nodeVersionInstall","error","message","versionsPath","join","installPath","installErr","results","result"],"mappings":"AAAA,OAAOA,UAAU,cAAc;AAC/B,OAAOC,UAAU,OAAO;AACxB,SAASC,WAAW,QAAQ,kBAAkB;AAC9C,OAAOC,4BAA4B,mCAAmC;AAEtE;;;;CAIC,GACD,eAAe,SAASC,WAAWC,IAAc;IAC/C,IAAIA,KAAKC,MAAM,KAAK,GAAG;QACrBC,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZR,KAAK;QACL;IACF;IAEA,MAAMS,UAAUJ,IAAI,CAAC,EAAE,CAACK,IAAI;IAE5B,sEAAsE;IACtE,IAAI,CAACD,WAAWA,QAAQE,OAAO,CAAC,SAAS,GAAG;QAC1CJ,QAAQC,GAAG,CAAC;QACZR,KAAK;QACL;IACF;IAEAO,QAAQC,GAAG,CAAC,CAAC,gBAAgB,EAAEC,QAAQ,GAAG,CAAC;IAE3C,wCAAwC;IACxCN,uBAAuB,CAACS,KAAKC;QAC3B,IAAID,OAAO,CAACC,oBAAoB;YAC9BN,QAAQO,KAAK,CAAC,wCAAwCF,CAAAA,gBAAAA,0BAAAA,IAAKG,OAAO,KAAI;YACtER,QAAQO,KAAK,CAAC;YACdd,KAAK;YACL;QACF;QAEA,MAAMgB,eAAef,KAAKgB,IAAI,CAACf,aAAa;QAE5CW,mBACEJ,SACA;YACES,aAAaF;QACf,GACA,CAACG,YAAoBC;YACnB,IAAID,YAAY;gBACdZ,QAAQO,KAAK,CAAC,CAAC,uBAAuB,EAAEL,QAAQ,CAAC,CAAC,EAAEU,WAAWJ,OAAO;gBACtEf,KAAK;gBACL;YACF;YAEA,IAAIoB,WAAWA,QAAQd,MAAM,GAAG,GAAG;gBACjC,MAAMe,SAASD,OAAO,CAAC,EAAE;gBACzBb,QAAQC,GAAG,CAAC,CAAC,4BAA4B,EAAEa,OAAOZ,OAAO,EAAE;gBAC3DF,QAAQC,GAAG,CAAC,CAAC,UAAU,EAAEa,OAAOH,WAAW,EAAE;YAC/C,OAAO;gBACLX,QAAQC,GAAG,CAAC,CAAC,KAAK,EAAEC,QAAQ,wBAAwB,CAAC;YACvD;YACAT,KAAK;QACP;IAEJ;AACF"}
@@ -1,4 +1,4 @@
1
- import exit from 'exit';
1
+ import exit from 'exit-compat';
2
2
  import fs from 'fs';
3
3
  import path from 'path';
4
4
  import { readdirWithTypes } from '../compat.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/list.ts"],"sourcesContent":["import exit from 'exit';\nimport fs from 'fs';\nimport path from 'path';\nimport { readdirWithTypes } from '../compat.ts';\nimport { storagePath } from '../constants.ts';\n\n/**\n * nvu list\n *\n * List all installed Node versions.\n */\nexport default function listCmd(_args: string[]): void {\n var versionsPath = path.join(storagePath, 'installed');\n\n // Check if versions directory exists\n if (!fs.existsSync(versionsPath)) {\n console.log('No Node versions installed.');\n console.log('Install a version: nvu install <version>');\n exit(0);\n return;\n }\n\n // Read all directories in versions folder\n var entries = readdirWithTypes(versionsPath);\n var versions = entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name);\n\n if (versions.length === 0) {\n console.log('No Node versions installed.');\n console.log('Install a version: nvu install <version>');\n exit(0);\n return;\n }\n\n // Get the current default\n const defaultFilePath = path.join(storagePath, 'default');\n let defaultVersion = '';\n if (fs.existsSync(defaultFilePath)) {\n defaultVersion = fs.readFileSync(defaultFilePath, 'utf8').trim();\n }\n\n // Sort versions (simple string sort, could be improved with semver)\n versions.sort((a, b) => {\n const aParts = a.split('.').map((n) => parseInt(n, 10) || 0);\n const bParts = b.split('.').map((n) => parseInt(n, 10) || 0);\n for (let i = 0; i < Math.max(aParts.length, bParts.length); i++) {\n const aVal = aParts[i] || 0;\n const bVal = bParts[i] || 0;\n if (aVal !== bVal) return bVal - aVal; // Descending order\n }\n return 0;\n });\n\n console.log('Installed Node versions:');\n for (let i = 0; i < versions.length; i++) {\n const version = versions[i];\n const isDefault = version === defaultVersion || `v${version}` === defaultVersion || version === `v${defaultVersion}`;\n const marker = isDefault ? ' (default)' : '';\n console.log(` ${version}${marker}`);\n }\n exit(0);\n}\n"],"names":["exit","fs","path","readdirWithTypes","storagePath","listCmd","_args","versionsPath","join","existsSync","console","log","entries","versions","filter","entry","isDirectory","map","name","length","defaultFilePath","defaultVersion","readFileSync","trim","sort","a","b","aParts","split","n","parseInt","bParts","i","Math","max","aVal","bVal","version","isDefault","marker"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AACxB,OAAOC,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AACxB,SAASC,gBAAgB,QAAQ,eAAe;AAChD,SAASC,WAAW,QAAQ,kBAAkB;AAE9C;;;;CAIC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,IAAIqB,IAAI,GAAGA,IAAInB,SAASM,MAAM,EAAEa,IAAK;QACxC,MAAMK,UAAUxB,QAAQ,CAACmB,EAAE;QAC3B,MAAMM,YAAYD,YAAYhB,kBAAkB,CAAC,CAAC,EAAEgB,SAAS,KAAKhB,kBAAkBgB,YAAY,CAAC,CAAC,EAAEhB,gBAAgB;QACpH,MAAMkB,SAASD,YAAY,eAAe;QAC1C5B,QAAQC,GAAG,CAAC,CAAC,EAAE,EAAE0B,UAAUE,QAAQ;IACrC;IACAvC,KAAK;AACP"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/list.ts"],"sourcesContent":["import exit from 'exit-compat';\nimport fs from 'fs';\nimport path from 'path';\nimport { readdirWithTypes } from '../compat.ts';\nimport { storagePath } from '../constants.ts';\n\n/**\n * nvu list\n *\n * List all installed Node versions.\n */\nexport default function listCmd(_args: string[]): void {\n var versionsPath = path.join(storagePath, 'installed');\n\n // Check if versions directory exists\n if (!fs.existsSync(versionsPath)) {\n console.log('No Node versions installed.');\n console.log('Install a version: nvu install <version>');\n exit(0);\n return;\n }\n\n // Read all directories in versions folder\n var entries = readdirWithTypes(versionsPath);\n var versions = entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name);\n\n if (versions.length === 0) {\n console.log('No Node versions installed.');\n console.log('Install a version: nvu install <version>');\n exit(0);\n return;\n }\n\n // Get the current default\n const defaultFilePath = path.join(storagePath, 'default');\n let defaultVersion = '';\n if (fs.existsSync(defaultFilePath)) {\n defaultVersion = fs.readFileSync(defaultFilePath, 'utf8').trim();\n }\n\n // Sort versions (simple string sort, could be improved with semver)\n versions.sort((a, b) => {\n const aParts = a.split('.').map((n) => parseInt(n, 10) || 0);\n const bParts = b.split('.').map((n) => parseInt(n, 10) || 0);\n for (let i = 0; i < Math.max(aParts.length, bParts.length); i++) {\n const aVal = aParts[i] || 0;\n const bVal = bParts[i] || 0;\n if (aVal !== bVal) return bVal - aVal; // Descending order\n }\n return 0;\n });\n\n console.log('Installed Node versions:');\n for (let i = 0; i < versions.length; i++) {\n const version = versions[i];\n const isDefault = version === defaultVersion || `v${version}` === defaultVersion || version === `v${defaultVersion}`;\n const marker = isDefault ? ' (default)' : '';\n console.log(` ${version}${marker}`);\n }\n exit(0);\n}\n"],"names":["exit","fs","path","readdirWithTypes","storagePath","listCmd","_args","versionsPath","join","existsSync","console","log","entries","versions","filter","entry","isDirectory","map","name","length","defaultFilePath","defaultVersion","readFileSync","trim","sort","a","b","aParts","split","n","parseInt","bParts","i","Math","max","aVal","bVal","version","isDefault","marker"],"mappings":"AAAA,OAAOA,UAAU,cAAc;AAC/B,OAAOC,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AACxB,SAASC,gBAAgB,QAAQ,eAAe;AAChD,SAASC,WAAW,QAAQ,kBAAkB;AAE9C;;;;CAIC,GACD,eAAe,SAASC,QAAQC,KAAe;IAC7C,IAAIC,eAAeL,KAAKM,IAAI,CAACJ,aAAa;IAE1C,qCAAqC;IACrC,IAAI,CAACH,GAAGQ,UAAU,CAACF,eAAe;QAChCG,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZX,KAAK;QACL;IACF;IAEA,0CAA0C;IAC1C,IAAIY,UAAUT,iBAAiBI;IAC/B,IAAIM,WAAWD,QAAQE,MAAM,CAAC,CAACC,QAAUA,MAAMC,WAAW,IAAIC,GAAG,CAAC,CAACF,QAAUA,MAAMG,IAAI;IAEvF,IAAIL,SAASM,MAAM,KAAK,GAAG;QACzBT,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZX,KAAK;QACL;IACF;IAEA,0BAA0B;IAC1B,MAAMoB,kBAAkBlB,KAAKM,IAAI,CAACJ,aAAa;IAC/C,IAAIiB,iBAAiB;IACrB,IAAIpB,GAAGQ,UAAU,CAACW,kBAAkB;QAClCC,iBAAiBpB,GAAGqB,YAAY,CAACF,iBAAiB,QAAQG,IAAI;IAChE;IAEA,oEAAoE;IACpEV,SAASW,IAAI,CAAC,CAACC,GAAGC;QAChB,MAAMC,SAASF,EAAEG,KAAK,CAAC,KAAKX,GAAG,CAAC,CAACY,IAAMC,SAASD,GAAG,OAAO;QAC1D,MAAME,SAASL,EAAEE,KAAK,CAAC,KAAKX,GAAG,CAAC,CAACY,IAAMC,SAASD,GAAG,OAAO;QAC1D,IAAK,IAAIG,IAAI,GAAGA,IAAIC,KAAKC,GAAG,CAACP,OAAOR,MAAM,EAAEY,OAAOZ,MAAM,GAAGa,IAAK;YAC/D,MAAMG,OAAOR,MAAM,CAACK,EAAE,IAAI;YAC1B,MAAMI,OAAOL,MAAM,CAACC,EAAE,IAAI;YAC1B,IAAIG,SAASC,MAAM,OAAOA,OAAOD,MAAM,mBAAmB;QAC5D;QACA,OAAO;IACT;IAEAzB,QAAQC,GAAG,CAAC;IACZ,IAAK,IAAIqB,IAAI,GAAGA,IAAInB,SAASM,MAAM,EAAEa,IAAK;QACxC,MAAMK,UAAUxB,QAAQ,CAACmB,EAAE;QAC3B,MAAMM,YAAYD,YAAYhB,kBAAkB,CAAC,CAAC,EAAEgB,SAAS,KAAKhB,kBAAkBgB,YAAY,CAAC,CAAC,EAAEhB,gBAAgB;QACpH,MAAMkB,SAASD,YAAY,eAAe;QAC1C5B,QAAQC,GAAG,CAAC,CAAC,EAAE,EAAE0B,UAAUE,QAAQ;IACrC;IACAvC,KAAK;AACP"}
@@ -1,4 +1,4 @@
1
- import exit from 'exit';
1
+ import exit from 'exit-compat';
2
2
  import fs from 'fs';
3
3
  import path from 'path';
4
4
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/local.ts"],"sourcesContent":["import exit from 'exit';\nimport fs from 'fs';\nimport path from 'path';\n\n/**\n * nvu local [version] [--nvurc]\n *\n * Write .nvmrc (or .nvurc) to the current directory.\n * This pins the Node version for the current project.\n */\nexport default function localCmd(args: string[]): void {\n const cwd = process.cwd();\n\n // Check for --nvurc flag (indexOf for Node 0.8+ compat)\n const useNvurc = args.indexOf('--nvurc') !== -1;\n const filteredArgs = args.filter((arg) => arg !== '--nvurc');\n\n const fileName = useNvurc ? '.nvurc' : '.nvmrc';\n const filePath = path.join(cwd, fileName);\n\n // If no version provided, display current local version\n if (filteredArgs.length === 0) {\n // Check for existing version files\n const nvurcPath = path.join(cwd, '.nvurc');\n const nvmrcPath = path.join(cwd, '.nvmrc');\n\n if (fs.existsSync(nvurcPath)) {\n const version = fs.readFileSync(nvurcPath, 'utf8').trim();\n console.log(`Current local version (.nvurc): ${version}`);\n exit(0);\n return;\n }\n if (fs.existsSync(nvmrcPath)) {\n const version = fs.readFileSync(nvmrcPath, 'utf8').trim();\n console.log(`Current local version (.nvmrc): ${version}`);\n exit(0);\n return;\n }\n\n console.log('No local version set in this directory.');\n console.log('Usage: nvu local <version>');\n console.log(' nvu local <version> --nvurc (use .nvurc instead of .nvmrc)');\n exit(0);\n return;\n }\n\n const version = filteredArgs[0].trim();\n\n // Validate version format (basic check, indexOf for Node 0.8+ compat)\n if (!version || version.indexOf('-') === 0) {\n console.log('Usage: nvu local <version>');\n console.log('Example: nvu local 20');\n exit(1);\n return;\n }\n\n // Write the version file\n fs.writeFileSync(filePath, `${version}\\n`, 'utf8');\n console.log(`Created ${fileName} with version: ${version}`);\n exit(0);\n}\n"],"names":["exit","fs","path","localCmd","args","cwd","process","useNvurc","indexOf","filteredArgs","filter","arg","fileName","filePath","join","length","nvurcPath","nvmrcPath","existsSync","version","readFileSync","trim","console","log","writeFileSync"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AACxB,OAAOC,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AAExB;;;;;CAKC,GACD,eAAe,SAASC,SAASC,IAAc;IAC7C,MAAMC,MAAMC,QAAQD,GAAG;IAEvB,wDAAwD;IACxD,MAAME,WAAWH,KAAKI,OAAO,CAAC,eAAe,CAAC;IAC9C,MAAMC,eAAeL,KAAKM,MAAM,CAAC,CAACC,MAAQA,QAAQ;IAElD,MAAMC,WAAWL,WAAW,WAAW;IACvC,MAAMM,WAAWX,KAAKY,IAAI,CAACT,KAAKO;IAEhC,wDAAwD;IACxD,IAAIH,aAAaM,MAAM,KAAK,GAAG;QAC7B,mCAAmC;QACnC,MAAMC,YAAYd,KAAKY,IAAI,CAACT,KAAK;QACjC,MAAMY,YAAYf,KAAKY,IAAI,CAACT,KAAK;QAEjC,IAAIJ,GAAGiB,UAAU,CAACF,YAAY;YAC5B,MAAMG,UAAUlB,GAAGmB,YAAY,CAACJ,WAAW,QAAQK,IAAI;YACvDC,QAAQC,GAAG,CAAC,CAAC,gCAAgC,EAAEJ,SAAS;YACxDnB,KAAK;YACL;QACF;QACA,IAAIC,GAAGiB,UAAU,CAACD,YAAY;YAC5B,MAAME,UAAUlB,GAAGmB,YAAY,CAACH,WAAW,QAAQI,IAAI;YACvDC,QAAQC,GAAG,CAAC,CAAC,gCAAgC,EAAEJ,SAAS;YACxDnB,KAAK;YACL;QACF;QAEAsB,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZvB,KAAK;QACL;IACF;IAEA,MAAMmB,UAAUV,YAAY,CAAC,EAAE,CAACY,IAAI;IAEpC,sEAAsE;IACtE,IAAI,CAACF,WAAWA,QAAQX,OAAO,CAAC,SAAS,GAAG;QAC1Cc,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZvB,KAAK;QACL;IACF;IAEA,yBAAyB;IACzBC,GAAGuB,aAAa,CAACX,UAAU,GAAGM,QAAQ,EAAE,CAAC,EAAE;IAC3CG,QAAQC,GAAG,CAAC,CAAC,QAAQ,EAAEX,SAAS,eAAe,EAAEO,SAAS;IAC1DnB,KAAK;AACP"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/local.ts"],"sourcesContent":["import exit from 'exit-compat';\nimport fs from 'fs';\nimport path from 'path';\n\n/**\n * nvu local [version] [--nvurc]\n *\n * Write .nvmrc (or .nvurc) to the current directory.\n * This pins the Node version for the current project.\n */\nexport default function localCmd(args: string[]): void {\n const cwd = process.cwd();\n\n // Check for --nvurc flag (indexOf for Node 0.8+ compat)\n const useNvurc = args.indexOf('--nvurc') !== -1;\n const filteredArgs = args.filter((arg) => arg !== '--nvurc');\n\n const fileName = useNvurc ? '.nvurc' : '.nvmrc';\n const filePath = path.join(cwd, fileName);\n\n // If no version provided, display current local version\n if (filteredArgs.length === 0) {\n // Check for existing version files\n const nvurcPath = path.join(cwd, '.nvurc');\n const nvmrcPath = path.join(cwd, '.nvmrc');\n\n if (fs.existsSync(nvurcPath)) {\n const version = fs.readFileSync(nvurcPath, 'utf8').trim();\n console.log(`Current local version (.nvurc): ${version}`);\n exit(0);\n return;\n }\n if (fs.existsSync(nvmrcPath)) {\n const version = fs.readFileSync(nvmrcPath, 'utf8').trim();\n console.log(`Current local version (.nvmrc): ${version}`);\n exit(0);\n return;\n }\n\n console.log('No local version set in this directory.');\n console.log('Usage: nvu local <version>');\n console.log(' nvu local <version> --nvurc (use .nvurc instead of .nvmrc)');\n exit(0);\n return;\n }\n\n const version = filteredArgs[0].trim();\n\n // Validate version format (basic check, indexOf for Node 0.8+ compat)\n if (!version || version.indexOf('-') === 0) {\n console.log('Usage: nvu local <version>');\n console.log('Example: nvu local 20');\n exit(1);\n return;\n }\n\n // Write the version file\n fs.writeFileSync(filePath, `${version}\\n`, 'utf8');\n console.log(`Created ${fileName} with version: ${version}`);\n exit(0);\n}\n"],"names":["exit","fs","path","localCmd","args","cwd","process","useNvurc","indexOf","filteredArgs","filter","arg","fileName","filePath","join","length","nvurcPath","nvmrcPath","existsSync","version","readFileSync","trim","console","log","writeFileSync"],"mappings":"AAAA,OAAOA,UAAU,cAAc;AAC/B,OAAOC,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AAExB;;;;;CAKC,GACD,eAAe,SAASC,SAASC,IAAc;IAC7C,MAAMC,MAAMC,QAA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1,5 @@
1
1
  import { execSync } from 'child_process';
2
- import exit from 'exit';
2
+ import exit from 'exit-compat';
3
3
  import fs from 'fs';
4
4
  import path from 'path';
5
5
  import url from 'url';
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/setup.ts"],"sourcesContent":["import { execSync } from 'child_process';\nimport exit from 'exit';\nimport fs from 'fs';\nimport path from 'path';\nimport url from 'url';\nimport { mkdirpSync } from '../compat.ts';\nimport { storagePath } from '../constants.ts';\n\nvar __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url));\n\n/**\n * nvu setup\n *\n * Install/reinstall nvu binaries to ~/.nvu/bin\n * This runs the same logic as the postinstall script.\n */\nexport default function setupCmd(_args: string[]): void {\n var binDir = path.join(storagePath, 'bin');\n\n // Create directories\n if (!fs.existsSync(storagePath)) {\n mkdirpSync(storagePath);\n }\n if (!fs.existsSync(binDir)) {\n mkdirpSync(binDir);\n }\n\n // Find the postinstall script relative to this module\n var postinstallPath = path.join(__dirname, '..', '..', '..', 'scripts', 'postinstall.cjs');\n\n if (fs.existsSync(postinstallPath)) {\n // Run the postinstall script\n try {\n execSync(`node \"${postinstallPath}\"`, { stdio: 'inherit' });\n } catch (_err) {\n // postinstall handles its own errors gracefully\n }\n } else {\n console.log('Setup script not found.');\n console.log('Try reinstalling: npm install -g node-version-use');\n exit(1);\n }\n}\n"],"names":["execSync","exit","fs","path","url","mkdirpSync","storagePath","__dirname","dirname","__filename","fileURLToPath","setupCmd","_args","binDir","join","existsSync","postinstallPath","stdio","_err","console","log"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,gBAAgB;AACzC,OAAOC,UAAU,OAAO;AACxB,OAAOC,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AACxB,OAAOC,SAAS,MAAM;AACtB,SAASC,UAAU,QAAQ,eAAe;AAC1C,SAASC,WAAW,QAAQ,kBAAkB;AAE9C,IAAIC,YAAYJ,KAAKK,OAAO,CAAC,OAAOC,eAAe,cAAcA,aAAaL,IAAIM,aAAa,CAAC,YAAYN,GAAG;AAE/G;;;;;CAKC,GACD,eAAe,SAASO,SAASC,KAAe;IAC9C,IAAIC,SAASV,KAAKW,IAAI,CAACR,aAAa;IAEpC,qBAAqB;IACrB,IAAI,CAACJ,GAAGa,UAAU,CAACT,cAAc;QAC/BD,WAAWC;IACb;IACA,IAAI,CAACJ,GAAGa,UAAU,CAACF,SAAS;QAC1BR,WAAWQ;IACb;IAEA,sDAAsD;IACtD,IAAIG,kBAAkBb,KAAKW,IAAI,CAACP,WAAW,MAAM,MAAM,MAAM,WAAW;IAExE,IAAIL,GAAGa,UAAU,CAACC,kBAAkB;QAClC,6BAA6B;QAC7B,IAAI;YACFhB,SAAS,CAAC,MAAM,EAAEgB,gBAAgB,CAAC,CAAC,EAAE;gBAAEC,OAAO;YAAU;QAC3D,EAAE,OAAOC,MAAM;QACb,gDAAgD;QAClD;IACF,OAAO;QACLC,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZnB,KAAK;IACP;AACF"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/setup.ts"],"sourcesContent":["import { execSync } from 'child_process';\nimport exit from 'exit-compat';\nimport fs from 'fs';\nimport path from 'path';\nimport url from 'url';\nimport { mkdirpSync } from '../compat.ts';\nimport { storagePath } from '../constants.ts';\n\nvar __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url));\n\n/**\n * nvu setup\n *\n * Install/reinstall nvu binaries to ~/.nvu/bin\n * This runs the same logic as the postinstall script.\n */\nexport default function setupCmd(_args: string[]): void {\n var binDir = path.join(storagePath, 'bin');\n\n // Create directories\n if (!fs.existsSync(storagePath)) {\n mkdirpSync(storagePath);\n }\n if (!fs.existsSync(binDir)) {\n mkdirpSync(binDir);\n }\n\n // Find the postinstall script relative to this module\n var postinstallPath = path.join(__dirname, '..', '..', '..', 'scripts', 'postinstall.cjs');\n\n if (fs.existsSync(postinstallPath)) {\n // Run the postinstall script\n try {\n execSync(`node \"${postinstallPath}\"`, { stdio: 'inherit' });\n } catch (_err) {\n // postinstall handles its own errors gracefully\n }\n } else {\n console.log('Setup script not found.');\n console.log('Try reinstalling: npm install -g node-version-use');\n exit(1);\n }\n}\n"],"names":["execSync","exit","fs","path","url","mkdirpSync","storagePath","__dirname","dirname","__filename","fileURLToPath","setupCmd","_args","binDir","join","existsSync","postinstallPath","stdio","_err","console","log"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,gBAAgB;AACzC,OAAOC,UAAU,cAAc;AAC/B,OAAOC,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AACxB,OAAOC,SAAS,MAAM;AACtB,SAASC,UAAU,QAAQ,eAAe;AAC1C,SAASC,WAAW,QAAQ,kBAAkB;AAE9C,IAAIC,YAAYJ,KAAKK,OAAO,CAAC,OAAOC,eAAe,cAAcA,aAAaL,IAAIM,aAAa,CAAC,YAAYN,GAAG;AAE/G;;;;;CAKC,GACD,eAAe,SAASO,SAASC,KAAe;IAC9C,IAAIC,SAASV,KAAKW,IAAI,CAACR,aAAa;IAEpC,qBAAqB;IACrB,IAAI,CAACJ,GAAGa,UAAU,CAACT,cAAc;QAC/BD,WAAWC;IACb;IACA,IAAI,CAACJ,GAAGa,UAAU,CAACF,SAAS;QAC1BR,WAAWQ;IACb;IAEA,sDAAsD;IACtD,IAAIG,kBAAkBb,KAAKW,IAAI,CAACP,WAAW,MAAM,MAAM,MAAM,WAAW;IAExE,IAAIL,GAAGa,UAAU,CAACC,kBAAkB;QAClC,6BAA6B;QAC7B,IAAI;YACFhB,SAAS,CAAC,MAAM,EAAEgB,gBAAgB,CAAC,CAAC,EAAE;gBAAEC,OAAO;YAAU;QAC3D,EAAE,OAAOC,MAAM;QACb,gDAAgD;QAClD;IACF,OAAO;QACLC,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZnB,KAAK;IACP;AACF"}
@@ -1,4 +1,4 @@
1
- import exit from 'exit';
1
+ import exit from 'exit-compat';
2
2
  import fs from 'fs';
3
3
  import { rmSync } from 'fs-remove-compat';
4
4
  import path from 'path';
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/teardown.ts"],"sourcesContent":["import exit from 'exit';\nimport fs from 'fs';\nimport { rmSync } from 'fs-remove-compat';\nimport path from 'path';\nimport { storagePath } from '../constants.ts';\n\n/**\n * nvu teardown\n *\n * Remove nvu binaries from ~/.nvu/bin\n */\nexport default function teardownCmd(_args: string[]): void {\n const binDir = path.join(storagePath, 'bin');\n\n const binaries = ['node', 'npm', 'npx'];\n const ext = process.platform === 'win32' ? '.exe' : '';\n\n let removed = 0;\n for (let i = 0; i < binaries.length; i++) {\n const binaryPath = path.join(binDir, binaries[i] + ext);\n if (fs.existsSync(binaryPath)) {\n rmSync(binaryPath, { force: true });\n removed++;\n }\n }\n\n if (removed > 0) {\n console.log(`Removed ${removed} binary(s) from ${binDir}`);\n console.log('');\n console.log('You may also want to remove ~/.nvu/bin from your PATH.');\n } else {\n console.log('No binaries found to remove.');\n }\n\n exit(0);\n}\n"],"names":["exit","fs","rmSync","path","storagePath","teardownCmd","_args","binDir","join","binaries","ext","process","platform","removed","i","length","binaryPath","existsSync","force","console","log"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AACxB,OAAOC,QAAQ,KAAK;AACpB,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,OAAOC,UAAU,OAAO;AACxB,SAASC,WAAW,QAAQ,kBAAkB;AAE9C;;;;CAIC,GACD,eAAe,SAASC,YAAYC,KAAe;IACjD,MAAMC,SAASJ,KAAKK,IAAI,CAACJ,aAAa;IAEtC,MAAMK,WAAW;QAAC;QAAQ;QAAO;KAAM;IACvC,MAAMC,MAAMC,QAAQC,QAAQ,KAAK,UAAU,SAAS;IAEpD,IAAIC,UAAU;IACd,IAAK,IAAIC,IAAI,GAAGA,IAAIL,SAASM,MAAM,EAAED,IAAK;QACxC,MAAME,aAAab,KAAKK,IAAI,CAACD,QAAQE,QAAQ,CAACK,EAAE,GAAGJ;QACnD,IAAIT,GAAGgB,UAAU,CAACD,aAAa;YAC7Bd,OAAOc,YAAY;gBAAEE,OAAO;YAAK;YACjCL;QACF;IACF;IAEA,IAAIA,UAAU,GAAG;QACfM,QAAQC,GAAG,CAAC,CAAC,QAAQ,EAAEP,QAAQ,gBAAgB,EAAEN,QAAQ;QACzDY,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;IACd,OAAO;QACLD,QAAQC,GAAG,CAAC;IACd;IAEApB,KAAK;AACP"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/teardown.ts"],"sourcesContent":["import exit from 'exit-compat';\nimport fs from 'fs';\nimport { rmSync } from 'fs-remove-compat';\nimport path from 'path';\nimport { storagePath } from '../constants.ts';\n\n/**\n * nvu teardown\n *\n * Remove nvu binaries from ~/.nvu/bin\n */\nexport default function teardownCmd(_args: string[]): void {\n const binDir = path.join(storagePath, 'bin');\n\n const binaries = ['node', 'npm', 'npx'];\n const ext = process.platform === 'win32' ? '.exe' : '';\n\n let removed = 0;\n for (let i = 0; i < binaries.length; i++) {\n const binaryPath = path.join(binDir, binaries[i] + ext);\n if (fs.existsSync(binaryPath)) {\n rmSync(binaryPath, { force: true });\n removed++;\n }\n }\n\n if (removed > 0) {\n console.log(`Removed ${removed} binary(s) from ${binDir}`);\n console.log('');\n console.log('You may also want to remove ~/.nvu/bin from your PATH.');\n } else {\n console.log('No binaries found to remove.');\n }\n\n exit(0);\n}\n"],"names":["exit","fs","rmSync","path","storagePath","teardownCmd","_args","binDir","join","binaries","ext","process","platform","removed","i","length","binaryPath","existsSync","force","console","log"],"mappings":"AAAA,OAAOA,UAAU,cAAc;AAC/B,OAAOC,QAAQ,KAAK;AACpB,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,OAAOC,UAAU,OAAO;AACxB,SAASC,WAAW,QAAQ,kBAAkB;AAE9C;;;;CAIC,GACD,eAAe,SAASC,YAAYC,KAAe;IACjD,MAAMC,SAASJ,KAAKK,IAAI,CAACJ,aAAa;IAEtC,MAAMK,WAAW;QAAC;QAAQ;QAAO;KAAM;IACvC,MAAMC,MAAMC,QAAQC,QAAQ,KAAK,UAAU,SAAS;IAEpD,IAAIC,UAAU;IACd,IAAK,IAAIC,IAAI,GAAGA,IAAIL,SAASM,MAAM,EAAED,IAAK;QACxC,MAAME,aAAab,KAAKK,IAAI,CAACD,QAAQE,QAAQ,CAACK,EAAE,GAAGJ;QACnD,IAAIT,GAAGgB,UAAU,CAACD,aAAa;YAC7Bd,OAAOc,YAAY;gBAAEE,OAAO;YAAK;YACjCL;QACF;IACF;IAEA,IAAIA,UAAU,GAAG;QACfM,QAAQC,GAAG,CAAC,CAAC,QAAQ,EAAEP,QAAQ,gBAAgB,EAAEN,QAAQ;QACzDY,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;IACd,OAAO;QACLD,QAAQC,GAAG,CAAC;IACd;IAEApB,KAAK;AACP"}
@@ -1,4 +1,4 @@
1
- import exit from 'exit';
1
+ import exit from 'exit-compat';
2
2
  import fs from 'fs';
3
3
  import path from 'path';
4
4
  import { readdirWithTypes, rmSync } from '../compat.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/uninstall.ts"],"sourcesContent":["import exit from 'exit';\nimport fs from 'fs';\nimport path from 'path';\nimport { readdirWithTypes, rmSync } from '../compat.ts';\nimport { storagePath } from '../constants.ts';\n\n/**\n * nvu uninstall <version>\n *\n * Remove an installed Node version.\n */\nexport default function uninstallCmd(args: string[]): void {\n if (args.length === 0) {\n console.log('Usage: nvu uninstall <version>');\n console.log('Example: nvu uninstall 20');\n console.log(' nvu uninstall v20.19.6');\n exit(1);\n return;\n }\n\n var version = args[0].trim();\n var versionsPath = path.join(storagePath, 'installed');\n\n // Find all matching installed versions\n var matches = findInstalledVersions(versionsPath, version);\n\n if (matches.length === 0) {\n console.log(`Node ${version} is not installed.`);\n console.log('');\n console.log('Installed versions:');\n listInstalledVersions(versionsPath);\n exit(1);\n return;\n }\n\n if (matches.length > 1) {\n console.log(`Multiple versions match \"${version}\":`);\n for (var i = 0; i < matches.length; i++) {\n console.log(` ${matches[i]}`);\n }\n console.log('');\n console.log('Please specify the exact version to uninstall.');\n exit(1);\n return;\n }\n\n var installedVersion = matches[0];\n var versionPath = path.join(versionsPath, installedVersion);\n\n // Check if this is the current default\n var defaultPath = path.join(storagePath, 'default');\n var isDefault = false;\n if (fs.existsSync(defaultPath)) {\n var defaultVersion = fs.readFileSync(defaultPath, 'utf8').trim();\n var normalizedDefault = defaultVersion.replace(/^v/, '');\n var normalizedInstalled = installedVersion.replace(/^v/, '');\n\n // Check if default matches this version\n if (normalizedInstalled === normalizedDefault || normalizedInstalled.indexOf(`${normalizedDefault}.`) === 0) {\n isDefault = true;\n }\n }\n\n // Remove the version directory\n try {\n rmSync(versionPath);\n console.log(`Removed Node ${installedVersion}`);\n\n if (isDefault) {\n // Clear the default since it's no longer installed\n fs.unlinkSync(defaultPath);\n console.log('');\n console.log('Note: This was your default version. Set a new default with:');\n console.log(' nvu default <version>');\n }\n } catch (err) {\n console.error(`Failed to remove Node ${installedVersion}:`, (err as Error).message);\n exit(1);\n return;\n }\n\n exit(0);\n}\n\n/**\n * Find all installed versions matching the given version string\n */\nfunction findInstalledVersions(versionsPath: string, version: string): string[] {\n if (!fs.existsSync(versionsPath)) {\n return [];\n }\n\n var normalizedVersion = version.replace(/^v/, '');\n var matches: string[] = [];\n\n // Try exact matches first\n var exactMatches = [version, `v${normalizedVersion}`, normalizedVersion];\n for (var i = 0; i < exactMatches.length; i++) {\n var v = exactMatches[i];\n var versionPath = path.join(versionsPath, v);\n if (fs.existsSync(versionPath) && fs.statSync(versionPath).isDirectory()) {\n if (matches.indexOf(v) === -1) {\n matches.push(v);\n }\n }\n }\n\n // If we have an exact match, return just that\n if (matches.length > 0) {\n return matches;\n }\n\n // Try partial match (e.g., \"20\" matches \"v20.19.6\")\n var entries = readdirWithTypes(versionsPath);\n for (var j = 0; j < entries.length; j++) {\n var entry = entries[j];\n if (!entry.isDirectory()) continue;\n var dirVersion = entry.name.replace(/^v/, '');\n if (dirVersion.indexOf(`${normalizedVersion}.`) === 0) {\n matches.push(entry.name);\n }\n }\n\n return matches;\n}\n\n/**\n * List installed versions for user reference\n */\nfunction listInstalledVersions(versionsPath: string): void {\n if (!fs.existsSync(versionsPath)) {\n console.log(' (none)');\n return;\n }\n\n var entries = readdirWithTypes(versionsPath);\n var versions: string[] = [];\n for (var i = 0; i < entries.length; i++) {\n if (entries[i].isDirectory()) {\n versions.push(entries[i].name);\n }\n }\n\n if (versions.length === 0) {\n console.log(' (none)');\n } else {\n for (var j = 0; j < versions.length; j++) {\n console.log(` ${versions[j]}`);\n }\n }\n}\n"],"names":["exit","fs","path","readdirWithTypes","rmSync","storagePath","uninstallCmd","args","length","console","log","version","trim","versionsPath","join","matches","findInstalledVersions","listInstalledVersions","i","installedVersion","versionPath","defaultPath","isDefault","existsSync","defaultVersion","readFileSync","normalizedDefault","replace","normalizedInstalled","indexOf","unlinkSync","err","error","message","normalizedVersion","exactMatches","v","statSync","isDirectory","push","entries","j","entry","dirVersion","name","versions"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AACxB,OAAOC,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AACxB,SAASC,gBAAgB,EAAEC,MAAM,QAAQ,eAAe;AACxD,SAASC,WAAW,QAAQ,kBAAkB;AAE9C;;;;CAIC,GACD,eAAe,SAASC,aAAaC,IAAc;IACjD,IAAIA,KAAKC,MAAM,KAAK,GAAG;QACrBC,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZV,KAAK;QACL;IACF;IAEA,IAAIW,UAAUJ,IAAI,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AI;QAC1B,IAAIK,aAAaD,MAAME,IAAI,CAACjB,OAAO,CAAC,MAAM;QAC1C,IAAIgB,WAAWd,OAAO,CAAC,GAAGK,kBAAkB,CAAC,CAAC,MAAM,GAAG;YACrDnB,QAAQwB,IAAI,CAACG,MAAME,IAAI;QACzB;IACF;IAEA,OAAO7B;AACT;AAEA;;CAEC,GACD,SAASE,sBAAsBJ,YAAoB;IACjD,IAAI,CAACZ,GAAGsB,UAAU,CAACV,eAAe;QAChCJ,QAAQC,GAAG,CAAC;QACZ;IACF;IAEA,IAAI8B,UAAUrC,iBAAiBU;IAC/B,IAAIgC,WAAqB,EAAE;IAC3B,IAAK,IAAI3B,IAAI,GAAGA,IAAIsB,QAAQhC,MAAM,EAAEU,IAAK;QACvC,IAAIsB,OAAO,CAACtB,EAAE,CAACoB,WAAW,IAAI;YAC5BO,SAASN,IAAI,CAACC,OAAO,CAACtB,EAAE,CAAC0B,IAAI;QAC/B;IACF;IAEA,IAAIC,SAASrC,MAAM,KAAK,GAAG;QACzBC,QAAQC,GAAG,CAAC;IACd,OAAO;QACL,IAAK,IAAI+B,IAAI,GAAGA,IAAII,SAASrC,MAAM,EAAEiC,IAAK;YACxChC,QAAQC,GAAG,CAAC,CAAC,EAAE,EAAEmC,QAAQ,CAACJ,EAAE,EAAE;QAChC;IACF;AACF"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/uninstall.ts"],"sourcesContent":["import exit from 'exit-compat';\nimport fs from 'fs';\nimport path from 'path';\nimport { readdirWithTypes, rmSync } from '../compat.ts';\nimport { storagePath } from '../constants.ts';\n\n/**\n * nvu uninstall <version>\n *\n * Remove an installed Node version.\n */\nexport default function uninstallCmd(args: string[]): void {\n if (args.length === 0) {\n console.log('Usage: nvu uninstall <version>');\n console.log('Example: nvu uninstall 20');\n console.log(' nvu uninstall v20.19.6');\n exit(1);\n return;\n }\n\n var version = args[0].trim();\n var versionsPath = path.join(storagePath, 'installed');\n\n // Find all matching installed versions\n var matches = findInstalledVersions(versionsPath, version);\n\n if (matches.length === 0) {\n console.log(`Node ${version} is not installed.`);\n console.log('');\n console.log('Installed versions:');\n listInstalledVersions(versionsPath);\n exit(1);\n return;\n }\n\n if (matches.length > 1) {\n console.log(`Multiple versions match \"${version}\":`);\n for (var i = 0; i < matches.length; i++) {\n console.log(` ${matches[i]}`);\n }\n console.log('');\n console.log('Please specify the exact version to uninstall.');\n exit(1);\n return;\n }\n\n var installedVersion = matches[0];\n var versionPath = path.join(versionsPath, installedVersion);\n\n // Check if this is the current default\n var defaultPath = path.join(storagePath, 'default');\n var isDefault = false;\n if (fs.existsSync(defaultPath)) {\n var defaultVersion = fs.readFileSync(defaultPath, 'utf8').trim();\n var normalizedDefault = defaultVersion.replace(/^v/, '');\n var normalizedInstalled = installedVersion.replace(/^v/, '');\n\n // Check if default matches this version\n if (normalizedInstalled === normalizedDefault || normalizedInstalled.indexOf(`${normalizedDefault}.`) === 0) {\n isDefault = true;\n }\n }\n\n // Remove the version directory\n try {\n rmSync(versionPath);\n console.log(`Removed Node ${installedVersion}`);\n\n if (isDefault) {\n // Clear the default since it's no longer installed\n fs.unlinkSync(defaultPath);\n console.log('');\n console.log('Note: This was your default version. Set a new default with:');\n console.log(' nvu default <version>');\n }\n } catch (err) {\n console.error(`Failed to remove Node ${installedVersion}:`, (err as Error).message);\n exit(1);\n return;\n }\n\n exit(0);\n}\n\n/**\n * Find all installed versions matching the given version string\n */\nfunction findInstalledVersions(versionsPath: string, version: string): string[] {\n if (!fs.existsSync(versionsPath)) {\n return [];\n }\n\n var normalizedVersion = version.replace(/^v/, '');\n var matches: string[] = [];\n\n // Try exact matches first\n var exactMatches = [version, `v${normalizedVersion}`, normalizedVersion];\n for (var i = 0; i < exactMatches.length; i++) {\n var v = exactMatches[i];\n var versionPath = path.join(versionsPath, v);\n if (fs.existsSync(versionPath) && fs.statSync(versionPath).isDirectory()) {\n if (matches.indexOf(v) === -1) {\n matches.push(v);\n }\n }\n }\n\n // If we have an exact match, return just that\n if (matches.length > 0) {\n return matches;\n }\n\n // Try partial match (e.g., \"20\" matches \"v20.19.6\")\n var entries = readdirWithTypes(versionsPath);\n for (var j = 0; j < entries.length; j++) {\n var entry = entries[j];\n if (!entry.isDirectory()) continue;\n var dirVersion = entry.name.replace(/^v/, '');\n if (dirVersion.indexOf(`${normalizedVersion}.`) === 0) {\n matches.push(entry.name);\n }\n }\n\n return matches;\n}\n\n/**\n * List installed versions for user reference\n */\nfunction listInstalledVersions(versionsPath: string): void {\n if (!fs.existsSync(versionsPath)) {\n console.log(' (none)');\n return;\n }\n\n var entries = readdirWithTypes(versionsPath);\n var versions: string[] = [];\n for (var i = 0; i < entries.length; i++) {\n if (entries[i].isDirectory()) {\n versions.push(entries[i].name);\n }\n }\n\n if (versions.length === 0) {\n console.log(' (none)');\n } else {\n for (var j = 0; j < versions.length; j++) {\n console.log(` ${versions[j]}`);\n }\n }\n}\n"],"names":["exit","fs","path","readdirWithTypes","rmSync","storagePath","uninstallCmd","args","length","console","log","version","trim","versionsPath","join","matches","findInstalledVersions","listInstalledVersions","i","installedVersion","versionPath","defaultPath","isDefault","existsSync","defaultVersion","readFileSync","normalizedDefault","replace","normalizedInstalled","indexOf","unlinkSync","err","error","message","normalizedVersion","exactMatches","v","statSync","isDirectory","push","entries","j","entry","dirVersion","name","versions"],"mappings":"AAAA,OAAOA,UAAU,cAAc;AAC/B,OAAOC,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AACxB,SAASC,gBAAgB,EAAEC,MAAM,QAAQ,eAAe;AACxD,SAASC,WAAW,QAAQ,kBAAkB;AAE9C;;;;CAIC,GACD,eAAe,SAASC,aAAaC,IAAc;IACjD,IAAIA,KAAKC,MAAM,KAAK,GAAG;QACrBC,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZV,KAAK;QACL;IACF;IAEA,IAAIW,UAAUJ,IAAI,CAAC,EAAE,CAACK,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aAAaD,MAAME,IAAI,CAACjB,OAAO,CAAC,MAAM;QAC1C,IAAIgB,WAAWd,OAAO,CAAC,GAAGK,kBAAkB,CAAC,CAAC,MAAM,GAAG;YACrDnB,QAAQwB,IAAI,CAACG,MAAME,IAAI;QACzB;IACF;IAEA,OAAO7B;AACT;AAEA;;CAEC,GACD,SAASE,sBAAsBJ,YAAoB;IACjD,IAAI,CAACZ,GAAGsB,UAAU,CAACV,eAAe;QAChCJ,QAAQC,GAAG,CAAC;QACZ;IACF;IAEA,IAAI8B,UAAUrC,iBAAiBU;IAC/B,IAAIgC,WAAqB,EAAE;IAC3B,IAAK,IAAI3B,IAAI,GAAGA,IAAIsB,QAAQhC,MAAM,EAAEU,IAAK;QACvC,IAAIsB,OAAO,CAACtB,EAAE,CAACoB,WAAW,IAAI;YAC5BO,SAASN,IAAI,CAACC,OAAO,CAACtB,EAAE,CAAC0B,IAAI;QAC/B;IACF;IAEA,IAAIC,SAASrC,MAAM,KAAK,GAAG;QACzBC,QAAQC,GAAG,CAAC;IACd,OAAO;QACL,IAAK,IAAI+B,IAAI,GAAGA,IAAII,SAASrC,MAAM,EAAEiC,IAAK;YACxChC,QAAQC,GAAG,CAAC,CAAC,EAAE,EAAEmC,QAAQ,CAACJ,EAAE,EAAE;QAChC;IACF;AACF"}
@@ -1,4 +1,4 @@
1
- import exit from 'exit';
1
+ import exit from 'exit-compat';
2
2
  import fs from 'fs';
3
3
  import path from 'path';
4
4
  import { storagePath } from '../constants.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/which.ts"],"sourcesContent":["import exit from 'exit';\nimport fs from 'fs';\nimport path from 'path';\nimport { storagePath } from '../constants.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 // Check if the version is installed\n const versionsPath = path.join(storagePath, 'installed');\n const versionPath = path.join(versionsPath, version);\n const versionPathWithV = path.join(versionsPath, `v${version}`);\n const versionPathWithoutV = path.join(versionsPath, version.replace(/^v/, ''));\n\n let actualVersionPath = '';\n if (fs.existsSync(versionPath)) {\n actualVersionPath = versionPath;\n } else if (fs.existsSync(versionPathWithV)) {\n actualVersionPath = versionPathWithV;\n } else if (fs.existsSync(versionPathWithoutV)) {\n actualVersionPath = versionPathWithoutV;\n }\n\n console.log(`Version: ${version}`);\n console.log(`Source: ${getVersionSource(cwd)}`);\n\n if (actualVersionPath) {\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","whichCmd","_args","cwd","process","version","resolveVersion","console","log","versionsPath","join","versionPath","versionPathWithV","versionPathWithoutV","replace","actualVersionPath","existsSync","getVersionSource","nodePath","dir","nvurcPath","readFileSync","trim","nvmrcPath","parent","dirname","defaultPath"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AACxB,OAAOC,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AACxB,SAASC,WAAW,QAAQ,kBAAkB;AAE9C;;;;;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;QACZX,KAAK;QACL;IACF;IAEA,oCAAoC;IACpC,MAAMY,eAAeV,KAAKW,IAAI,CAACV,aAAa;IAC5C,MAAMW,cAAcZ,KAAKW,IAAI,CAACD,cAAcJ;IAC5C,MAAMO,mBAAmBb,KAAKW,IAAI,CAACD,cAAc,CAAC,CAAC,EAAEJ,SAAS;IAC9D,MAAMQ,sBAAsBd,KAAKW,IAAI,CAACD,cAAcJ,QAAQS,OAAO,CAAC,MAAM;IAE1E,IAAIC,oBAAoB;IACxB,IAAIjB,GAAGkB,UAAU,CAACL,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Ac;QAC9B,OAAO5B,GAAGuB,YAAY,CAACK,aAAa,QAAQJ,IAAI;IAClD;IAEA,OAAO;AACT;AAEA;;CAEC,GACD,SAASL,iBAAiBd,GAAW;IACnC,IAAIgB,MAAMhB;IACV,MAAO,KAAM;QACX,MAAMiB,YAAYrB,KAAKW,IAAI,CAACS,KAAK;QACjC,IAAIrB,GAAGkB,UAAU,CAACI,YAAY;YAC5B,OAAOA;QACT;QAEA,MAAMG,YAAYxB,KAAKW,IAAI,CAACS,KAAK;QACjC,IAAIrB,GAAGkB,UAAU,CAACO,YAAY;YAC5B,OAAOA;QACT;QAEA,MAAMC,SAASzB,KAAK0B,OAAO,CAACN;QAC5B,IAAIK,WAAWL,KAAK;QACpBA,MAAMK;IACR;IAEA,MAAME,cAAc3B,KAAKW,IAAI,CAACV,aAAa;IAC3C,IAAIF,GAAGkB,UAAU,CAACU,cAAc;QAC9B,OAAO,GAAGA,YAAY,iBAAiB,CAAC;IAC1C;IAEA,OAAO;AACT"}
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';\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 // Check if the version is installed\n const versionsPath = path.join(storagePath, 'installed');\n const versionPath = path.join(versionsPath, version);\n const versionPathWithV = path.join(versionsPath, `v${version}`);\n const versionPathWithoutV = path.join(versionsPath, version.replace(/^v/, ''));\n\n let actualVersionPath = '';\n if (fs.existsSync(versionPath)) {\n actualVersionPath = versionPath;\n } else if (fs.existsSync(versionPathWithV)) {\n actualVersionPath = versionPathWithV;\n } else if (fs.existsSync(versionPathWithoutV)) {\n actualVersionPath = versionPathWithoutV;\n }\n\n console.log(`Version: ${version}`);\n console.log(`Source: ${getVersionSource(cwd)}`);\n\n if (actualVersionPath) {\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","whichCmd","_args","cwd","process","version","resolveVersion","console","log","versionsPath","join","versionPath","versionPathWithV","versionPathWithoutV","replace","actualVersionPath","existsSync","getVersionSource","nodePath","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;AAE9C;;;;;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;QACZX,KAAK;QACL;IACF;IAEA,oCAAoC;IACpC,MAAMY,eAAeV,KAAKW,IAAI,CAACV,aAAa;IAC5C,MAAMW,cAAcZ,KAAKW,IAAI,CAACD,cAAcJ;IAC5C,MAAMO,mBAAmBb,KAAKW,IAAI,CAACD,cAAc,CAAC,CAAC,EAAEJ,SAAS;IAC9D,MAAMQ,sBAAsBd,KAAKW,IAAI,CAACD,cAAcJ,QAAQS,OAAO,CAAC,MAAM;IAE1E,IAAIC,oBAAoB;IACxB,IAAIjB,GAAGkB,UAAU,CAACL,cAAc;QAC9BI,oBAAoBJ;IACtB,OAAO,IAAIb,GAAGkB,UAAU,CAACJ,mBAAmB;QAC1CG,oBAAoBH;IACtB,OAAO,IAAId,GAAGkB,UAAU,CAACH,sBAAsB;QAC7CE,oBAAoBF;IACtB;IAEAN,QAAQC,GAAG,CAAC,CAAC,SAAS,EAAEH,SAAS;IACjCE,QAAQC,GAAG,CAAC,CAAC,QAAQ,EAAES,iBAAiBd,MAAM;IAE9C,IAAIY,mBAAmB;QACrB,MAAMG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AAK;QACjC,IAAIrB,GAAGkB,UAAU,CAACO,YAAY;YAC5B,OAAOA;QACT;QAEA,MAAMC,SAASzB,KAAK0B,OAAO,CAACN;QAC5B,IAAIK,WAAWL,KAAK;QACpBA,MAAMK;IACR;IAEA,MAAME,cAAc3B,KAAKW,IAAI,CAACV,aAAa;IAC3C,IAAIF,GAAGkB,UAAU,CAACU,cAAc;QAC9B,OAAO,GAAGA,YAAY,iBAAiB,CAAC;IAC1C;IAEA,OAAO;AACT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-version-use",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "Cross-platform solution for using multiple versions of node. Useful for compatibility testing",
5
5
  "keywords": [
6
6
  "node",
@@ -49,11 +49,11 @@
49
49
  },
50
50
  "dependencies": {
51
51
  "cross-spawn-cb": "^2.4.10",
52
- "exit": "^0.1.2",
52
+ "exit-compat": "^1.0.0",
53
53
  "fs-remove-compat": "^0.2.1",
54
54
  "getopts-compat": "^2.2.6",
55
55
  "homedir-polyfill": "^1.0.3",
56
- "install-module-linked": "^1.3.11",
56
+ "install-module-linked": "^1.3.12",
57
57
  "mkdirp-classic": "^0.5.3",
58
58
  "node-resolve-versions": "^1.3.11",
59
59
  "node-version-utils": "^1.3.15",
@@ -71,7 +71,7 @@
71
71
  "is-version": "^1.0.7",
72
72
  "mkdirp-classic": "^0.5.3",
73
73
  "node-version-install": "^1.4.18",
74
- "node-version-use": "^2.0.0",
74
+ "node-version-use": "^2.1.0",
75
75
  "os-shim": "^0.1.3",
76
76
  "pinkie-promise": "^2.0.1",
77
77
  "ts-dev-stack": "^1.21.2",
@@ -15,7 +15,7 @@
15
15
  var fs = require('fs');
16
16
  var path = require('path');
17
17
  var os = require('os');
18
- var exit = require('exit');
18
+ var exit = require('exit-compat');
19
19
 
20
20
  // Polyfills for old Node versions
21
21
  var mkdirp = require('mkdirp-classic');