node-version-use 0.4.8 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/cli.js CHANGED
@@ -70,9 +70,4 @@ var _default = function(argv, name) {
70
70
  (0, _exit.default)(errors.length ? -1 : 0);
71
71
  });
72
72
  };
73
-
74
- if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
75
- Object.defineProperty(exports.default, '__esModule', { value: true });
76
- for (var key in exports) exports.default[key] = exports[key];
77
- module.exports = exports.default;
78
- }
73
+ /* CJS INTEROP */ if (exports.__esModule && exports.default) { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) exports.default[key] = exports[key]; module.exports = exports.default; }
@@ -1 +1 @@
1
- {"version":3,"sources":["cli.js"],"sourcesContent":["import exit from 'exit';\nimport getopts from 'getopts-compat';\nimport nvu from './index.js';\n\nexport default (argv, name) => {\n const options = getopts(argv.slice(1), {\n alias: { range: 'r', desc: 'd', silent: 's' },\n default: { range: 'major,even' },\n boolean: ['silent', 'desc'],\n stopEarly: true,\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 const args = argv.slice(0, 1).concat(options._);\n if (args.length < 1) {\n console.log(`Missing command. Example usage: ${name} [version expression] [command]`);\n return exit(-1);\n }\n\n if (!options.silent)\n options.header = (version, command, args) => {\n console.log('\\n----------------------');\n console.log(`${[command].concat(args).join(' ')} (${version})`);\n console.log('----------------------');\n };\n\n options.stdio = 'inherit'; // pass through stdio\n nvu(args[0], args[1], args.slice(2), options, (err, results) => {\n if (err) {\n console.log(err.message);\n return exit(err.code || -1);\n }\n const errors = results.filter((result) => !!result.error);\n\n if (!options.silent) {\n console.log('\\n======================');\n if (errors.length) {\n console.log(`Errors (${errors.length})`);\n for (let index = 0; index < errors.length; index++) {\n const result = errors[index];\n console.log(`${result.version} Error: ${result.error.message}`);\n }\n } else console.log(`Success (${results.length})`);\n console.log('======================');\n }\n\n exit(errors.length ? -1 : 0);\n });\n};\n"],"names":["argv","name","options","getopts","slice","alias","range","desc","silent","default","boolean","stopEarly","sort","args","concat","_","length","console","log","exit","header","version","command","join","stdio","nvu","err","results","message","code","errors","filter","result","error","index"],"mappings":";;;;+BAIA;;;eAAA;;;2DAJiB;oEACG;4DACJ;;;;;;IAEhB,WAAe,SAACA,MAAMC;IACpB,IAAMC,UAAUC,IAAAA,sBAAO,EAACH,KAAKI,KAAK,CAAC,IAAI;QACrCC,OAAO;YAAEC,OAAO;YAAKC,MAAM;YAAKC,QAAQ;QAAI;QAC5CC,SAAS;YAAEH,OAAO;QAAa;QAC/BI,SAAS;YAAC;YAAU;SAAO;QAC3BC,WAAW;IACb;IAEA,4JAA4J;IAC5J,4DAA4D;IAC5DT,QAAQU,IAAI,GAAGV,QAAQK,IAAI,GAAG,CAAC,IAAI;IAEnC,IAAMM,OAAOb,KAAKI,KAAK,CAAC,GAAG,GAAGU,MAAM,CAACZ,QAAQa,CAAC;IAC9C,IAAIF,KAAKG,MAAM,GAAG,GAAG;QACnBC,QAAQC,GAAG,CAAC,AAAC,mCAAuC,OAALjB,MAAK;QACpD,OAAOkB,IAAAA,aAAI,EAAC,CAAC;IACf;IAEA,IAAI,CAACjB,QAAQM,MAAM,EACjBN,QAAQkB,MAAM,GAAG,SAACC,SAASC,SAAST;QAClCI,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC,AAAC,GAAuCG,OAArC;YAACC;SAAQ,CAACR,MAAM,CAACD,MAAMU,IAAI,CAAC,MAAK,MAAY,OAARF,SAAQ;QAC5DJ,QAAQC,GAAG,CAAC;IACd;IAEFhB,QAAQsB,KAAK,GAAG,WAAW,qBAAqB;IAChDC,IAAAA,cAAG,EAACZ,IAAI,CAAC,EAAE,EAAEA,IAAI,CAAC,EAAE,EAAEA,KAAKT,KAAK,CAAC,IAAIF,SAAS,SAACwB,KAAKC;QAClD,IAAID,KAAK;YACPT,QAAQC,GAAG,CAACQ,IAAIE,OAAO;YACvB,OAAOT,IAAAA,aAAI,EAACO,IAAIG,IAAI,IAAI,CAAC;QAC3B;QACA,IAAMC,SAASH,QAAQI,MAAM,CAAC,SAACC;mBAAW,CAAC,CAACA,OAAOC,KAAK;;QAExD,IAAI,CAAC/B,QAAQM,MAAM,EAAE;YACnBS,QAAQC,GAAG,CAAC;YACZ,IAAIY,OAAOd,MAAM,EAAE;gBACjBC,QAAQC,GAAG,CAAC,AAAC,WAAwB,OAAdY,OAAOd,MAAM,EAAC;gBACrC,IAAK,IAAIkB,QAAQ,GAAGA,QAAQJ,OAAOd,MAAM,EAAEkB,QAAS;oBAClD,IAAMF,SAASF,MAAM,CAACI,MAAM;oBAC5BjB,QAAQC,GAAG,CAAC,AAAC,GAA2Bc,OAAzBA,OAAOX,OAAO,EAAC,YAA+B,OAArBW,OAAOC,KAAK,CAACL,OAAO;gBAC9D;YACF,OAAOX,QAAQC,GAAG,CAAC,AAAC,YAA0B,OAAfS,QAAQX,MAAM,EAAC;YAC9CC,QAAQC,GAAG,CAAC;QACd;QAEAC,IAAAA,aAAI,EAACW,OAAOd,MAAM,GAAG,CAAC,IAAI;IAC5B;AACF"}
1
+ {"version":3,"sources":["cli.js"],"sourcesContent":["import exit from 'exit';\nimport getopts from 'getopts-compat';\nimport nvu from './index.mjs';\n\nexport default (argv, name) => {\n const options = getopts(argv.slice(1), {\n alias: { range: 'r', desc: 'd', silent: 's' },\n default: { range: 'major,even' },\n boolean: ['silent', 'desc'],\n stopEarly: true,\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 const args = argv.slice(0, 1).concat(options._);\n if (args.length < 1) {\n console.log(`Missing command. Example usage: ${name} [version expression] [command]`);\n return exit(-1);\n }\n\n if (!options.silent)\n options.header = (version, command, args) => {\n console.log('\\n----------------------');\n console.log(`${[command].concat(args).join(' ')} (${version})`);\n console.log('----------------------');\n };\n\n options.stdio = 'inherit'; // pass through stdio\n nvu(args[0], args[1], args.slice(2), options, (err, results) => {\n if (err) {\n console.log(err.message);\n return exit(err.code || -1);\n }\n const errors = results.filter((result) => !!result.error);\n\n if (!options.silent) {\n console.log('\\n======================');\n if (errors.length) {\n console.log(`Errors (${errors.length})`);\n for (let index = 0; index < errors.length; index++) {\n const result = errors[index];\n console.log(`${result.version} Error: ${result.error.message}`);\n }\n } else console.log(`Success (${results.length})`);\n console.log('======================');\n }\n\n exit(errors.length ? -1 : 0);\n });\n};\n"],"names":["argv","name","options","getopts","slice","alias","range","desc","silent","default","boolean","stopEarly","sort","args","concat","_","length","console","log","exit","header","version","command","join","stdio","nvu","err","results","message","code","errors","filter","result","error","index"],"mappings":";;;;+BAIA;;;eAAA;;;2DAJiB;oEACG;4DACJ;;;;;;IAEhB,WAAe,SAACA,MAAMC;IACpB,IAAMC,UAAUC,IAAAA,sBAAO,EAACH,KAAKI,KAAK,CAAC,IAAI;QACrCC,OAAO;YAAEC,OAAO;YAAKC,MAAM;YAAKC,QAAQ;QAAI;QAC5CC,SAAS;YAAEH,OAAO;QAAa;QAC/BI,SAAS;YAAC;YAAU;SAAO;QAC3BC,WAAW;IACb;IAEA,4JAA4J;IAC5J,4DAA4D;IAC5DT,QAAQU,IAAI,GAAGV,QAAQK,IAAI,GAAG,CAAC,IAAI;IAEnC,IAAMM,OAAOb,KAAKI,KAAK,CAAC,GAAG,GAAGU,MAAM,CAACZ,QAAQa,CAAC;IAC9C,IAAIF,KAAKG,MAAM,GAAG,GAAG;QACnBC,QAAQC,GAAG,CAAC,AAAC,mCAAuC,OAALjB,MAAK;QACpD,OAAOkB,IAAAA,aAAI,EAAC,CAAC;IACf;IAEA,IAAI,CAACjB,QAAQM,MAAM,EACjBN,QAAQkB,MAAM,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, ".nvu", "installed")
7
7
  };
8
-
9
- if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
10
- Object.defineProperty(exports.default, '__esModule', { value: true });
11
- for (var key in exports) exports.default[key] = exports[key];
12
- module.exports = exports.default;
13
- }
8
+ /* CJS INTEROP */ if (exports.__esModule && exports.default) { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) exports.default[key] = exports[key]; module.exports = exports.default; }
package/dist/cjs/index.js CHANGED
@@ -1,27 +1,47 @@
1
1
  "use strict";
2
- var use = require("./use");
3
- var constants = require("./constants");
4
- module.exports = function nodeVersionUse(versionExpression, command, args, options, callback) {
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ cacheDirectory: function() {
13
+ return cacheDirectory;
14
+ },
15
+ default: function() {
16
+ return nodeVersionUse;
17
+ },
18
+ installDirectory: function() {
19
+ return installDirectory;
20
+ }
21
+ });
22
+ var _constants = /*#__PURE__*/ _interop_require_default(require("./constants"));
23
+ var _use = /*#__PURE__*/ _interop_require_default(require("./use"));
24
+ function _interop_require_default(obj) {
25
+ return obj && obj.__esModule ? obj : {
26
+ default: obj
27
+ };
28
+ }
29
+ function nodeVersionUse(versionExpression, command, args, options, callback) {
5
30
  if (typeof options === "function") {
6
31
  callback = options;
7
32
  options = {};
8
33
  }
9
- if (typeof callback === "function") return use(versionExpression, command, args, options || {}, callback);
34
+ if (typeof callback === "function") return (0, _use.default)(versionExpression, command, args, options || {}, callback);
10
35
  return new Promise(function(resolve, reject) {
11
36
  nodeVersionUse(versionExpression, command, args, options, function nodeVersionUseCallback(err, res) {
12
37
  err ? reject(err) : resolve(res);
13
38
  });
14
39
  });
15
- };
16
- module.exports.installDirectory = function installDirectory() {
17
- return constants.installDirectory;
18
- };
19
- module.exports.cacheDirectory = function cacheDirectory(_options) {
20
- return constants.cacheDirectory;
21
- };
22
-
23
- if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
24
- Object.defineProperty(exports.default, '__esModule', { value: true });
25
- for (var key in exports) exports.default[key] = exports[key];
26
- module.exports = exports.default;
27
- }
40
+ }
41
+ function installDirectory() {
42
+ return _constants.default.installDirectory;
43
+ }
44
+ function cacheDirectory(_options) {
45
+ return _constants.default.cacheDirectory;
46
+ }
47
+ /* CJS INTEROP */ if (exports.__esModule && exports.default) { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) exports.default[key] = exports[key]; module.exports = exports.default; }
@@ -1 +1 @@
1
- {"version":3,"sources":["index.js"],"sourcesContent":["const use = require('./use');\nconst constants = require('./constants');\n\nmodule.exports = function nodeVersionUse(versionExpression, command, args, options, callback) {\n if (typeof options === 'function') {\n callback = options;\n options = {};\n }\n if (typeof callback === 'function') return use(versionExpression, command, args, options || {}, callback);\n return new Promise((resolve, reject) => {\n nodeVersionUse(versionExpression, command, args, options, function nodeVersionUseCallback(err, res) {\n err ? reject(err) : resolve(res);\n });\n });\n};\n\nmodule.exports.installDirectory = function installDirectory() {\n return constants.installDirectory;\n};\n\nmodule.exports.cacheDirectory = function cacheDirectory(_options) {\n return constants.cacheDirectory;\n};\n"],"names":["use","require","constants","module","exports","nodeVersionUse","versionExpression","command","args","options","callback","Promise","resolve","reject","nodeVersionUseCallback","err","res","installDirectory","cacheDirectory","_options"],"mappings":";AAAA,IAAMA,MAAMC,QAAQ;AACpB,IAAMC,YAAYD,QAAQ;AAE1BE,OAAOC,OAAO,GAAG,SAASC,eAAeC,iBAAiB,EAAEC,OAAO,EAAEC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IAC1F,IAAI,OAAOD,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU,CAAC;IACb;IACA,IAAI,OAAOC,aAAa,YAAY,OAAOV,IAAIM,mBAAmBC,SAASC,MAAMC,WAAW,CAAC,GAAGC;IAChG,OAAO,IAAIC,QAAQ,SAACC,SAASC;QAC3BR,eAAeC,mBAAmBC,SAASC,MAAMC,SAAS,SAASK,uBAAuBC,GAAG,EAAEC,GAAG;YAChGD,MAAMF,OAAOE,OAAOH,QAAQI;QAC9B;IACF;AACF;AAEAb,OAAOC,OAAO,CAACa,gBAAgB,GAAG,SAASA;IACzC,OAAOf,UAAUe,gBAAgB;AACnC;AAEAd,OAAOC,OAAO,CAACc,cAAc,GAAG,SAASA,eAAeC,QAAQ;IAC9D,OAAOjB,UAAUgB,cAAc;AACjC"}
1
+ {"version":3,"sources":["index.mjs"],"sourcesContent":["import constants from './constants';\nimport use from './use';\n\nexport default function nodeVersionUse(versionExpression, command, args, options, callback) {\n if (typeof options === 'function') {\n callback = options;\n options = {};\n }\n if (typeof callback === 'function') return use(versionExpression, command, args, options || {}, callback);\n return new Promise((resolve, reject) => {\n nodeVersionUse(versionExpression, command, args, options, function nodeVersionUseCallback(err, res) {\n err ? reject(err) : resolve(res);\n });\n });\n}\n\nexport function installDirectory() {\n return constants.installDirectory;\n}\n\nexport function cacheDirectory(_options) {\n return constants.cacheDirectory;\n}\n"],"names":["cacheDirectory","nodeVersionUse","installDirectory","versionExpression","command","args","options","callback","use","Promise","resolve","reject","nodeVersionUseCallback","err","res","constants","_options"],"mappings":";;;;;;;;;;;IAoBgBA,cAAc;eAAdA;;IAjBhB,OAWC;eAXuBC;;IAaRC,gBAAgB;eAAhBA;;;gEAhBM;0DACN;;;;;;AAED,SAASD,eAAeE,iBAAiB,EAAEC,OAAO,EAAEC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IACxF,IAAI,OAAOD,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU,CAAC;IACb;IACA,IAAI,OAAOC,aAAa,YAAY,OAAOC,IAAAA,YAAG,EAACL,mBAAmBC,SAASC,MAAMC,WAAW,CAAC,GAAGC;IAChG,OAAO,IAAIE,QAAQ,SAACC,SAASC;QAC3BV,eAAeE,mBAAmBC,SAASC,MAAMC,SAAS,SAASM,uBAAuBC,GAAG,EAAEC,GAAG;YAChGD,MAAMF,OAAOE,OAAOH,QAAQI;QAC9B;IACF;AACF;AAEO,SAASZ;IACd,OAAOa,kBAAS,CAACb,gBAAgB;AACnC;AAEO,SAASF,eAAegB,QAAQ;IACrC,OAAOD,kBAAS,CAACf,cAAc;AACjC"}
package/dist/cjs/use.js CHANGED
@@ -1,6 +1,57 @@
1
1
  "use strict";
2
+ function _define_property(obj, key, value) {
3
+ if (key in obj) {
4
+ Object.defineProperty(obj, key, {
5
+ value: value,
6
+ enumerable: true,
7
+ configurable: true,
8
+ writable: true
9
+ });
10
+ } else {
11
+ obj[key] = value;
12
+ }
13
+ return obj;
14
+ }
15
+ function _object_spread(target) {
16
+ for(var i = 1; i < arguments.length; i++){
17
+ var source = arguments[i] != null ? arguments[i] : {};
18
+ var ownKeys = Object.keys(source);
19
+ if (typeof Object.getOwnPropertySymbols === "function") {
20
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
21
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
22
+ }));
23
+ }
24
+ ownKeys.forEach(function(key) {
25
+ _define_property(target, key, source[key]);
26
+ });
27
+ }
28
+ return target;
29
+ }
30
+ function ownKeys(object, enumerableOnly) {
31
+ var keys = Object.keys(object);
32
+ if (Object.getOwnPropertySymbols) {
33
+ var symbols = Object.getOwnPropertySymbols(object);
34
+ if (enumerableOnly) {
35
+ symbols = symbols.filter(function(sym) {
36
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
37
+ });
38
+ }
39
+ keys.push.apply(keys, symbols);
40
+ }
41
+ return keys;
42
+ }
43
+ function _object_spread_props(target, source) {
44
+ source = source != null ? source : {};
45
+ if (Object.getOwnPropertyDescriptors) {
46
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
47
+ } else {
48
+ ownKeys(Object(source)).forEach(function(key) {
49
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
50
+ });
51
+ }
52
+ return target;
53
+ }
2
54
  var path = require("path");
3
- var assign = require("just-extend");
4
55
  var Queue = require("queue-cb");
5
56
  var installRelease = require("node-install-release");
6
57
  var versionUtils = require("node-version-utils");
@@ -16,7 +67,7 @@ var spawnKeys = [
16
67
  "env"
17
68
  ];
18
69
  module.exports = function use(versionExpression, command, args, options, callback) {
19
- resolveVersions(versionExpression, assign({}, options, {
70
+ resolveVersions(versionExpression, _object_spread_props(_object_spread({}, options), {
20
71
  path: "raw"
21
72
  }), function(err, versions) {
22
73
  if (err) return callback(err);
@@ -55,9 +106,4 @@ module.exports = function use(versionExpression, command, args, options, callbac
55
106
  });
56
107
  });
57
108
  };
58
-
59
- if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
60
- Object.defineProperty(exports.default, '__esModule', { value: true });
61
- for (var key in exports) exports.default[key] = exports[key];
62
- module.exports = exports.default;
63
- }
109
+ /* CJS INTEROP */ if (exports.__esModule && exports.default) { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) exports.default[key] = exports[key]; module.exports = exports.default; }
@@ -1 +1 @@
1
- {"version":3,"sources":["use.js"],"sourcesContent":["const path = require('path');\nconst assign = require('just-extend');\nconst Queue = require('queue-cb');\nconst installRelease = require('node-install-release');\nconst versionUtils = require('node-version-utils');\nconst resolveVersions = require('node-resolve-versions');\n\nconst constants = require('./constants');\nconst spawnKeys = ['encoding', 'stdio', 'stdin', 'stdout', 'stderr', 'cwd', 'env'];\n\nmodule.exports = function use(versionExpression, command, args, options, callback) {\n resolveVersions(versionExpression, assign({}, options, { path: 'raw' }), (err, versions) => {\n if (err) return callback(err);\n if (!versions.length) return callback(new Error(`No versions found from expression: ${versionExpression}`));\n\n const spawnOptions = {};\n for (let i = 0; i < spawnKeys.length; i++) {\n if (options[spawnKeys[i]] !== undefined) spawnOptions[spawnKeys[i]] = options[spawnKeys[i]];\n }\n\n const results = [];\n const queue = new Queue(1);\n for (let index = 0; index < versions.length; index++) {\n ((version) => {\n queue.defer((callback) => {\n !options.header || options.header(version.version, command, args);\n\n const installDirectory = options.installDirectory || constants.installDirectory;\n const cacheDirectory = options.cacheDirectory || constants.cacheDirectory;\n const installPath = path.join(installDirectory, version.version);\n\n installRelease(version, installPath, { cacheDirectory: cacheDirectory }, (err) => {\n if (err) return callback(err);\n\n versionUtils.spawn(installPath, command, args, spawnOptions, (err, res) => {\n results.push({ version: version.version, error: err, result: res });\n callback();\n });\n });\n });\n })(versions[index]);\n }\n queue.await((err) => {\n err ? callback(err) : callback(null, results);\n });\n });\n};\n"],"names":["path","require","assign","Queue","installRelease","versionUtils","resolveVersions","constants","spawnKeys","module","exports","use","versionExpression","command","args","options","callback","err","versions","length","Error","spawnOptions","i","undefined","results","queue","index","version","defer","header","installDirectory","cacheDirectory","installPath","join","spawn","res","push","error","result","await"],"mappings":";AAAA,IAAMA,OAAOC,QAAQ;AACrB,IAAMC,SAASD,QAAQ;AACvB,IAAME,QAAQF,QAAQ;AACtB,IAAMG,iBAAiBH,QAAQ;AAC/B,IAAMI,eAAeJ,QAAQ;AAC7B,IAAMK,kBAAkBL,QAAQ;AAEhC,IAAMM,YAAYN,QAAQ;AAC1B,IAAMO,YAAY;IAAC;IAAY;IAAS;IAAS;IAAU;IAAU;IAAO;CAAM;AAElFC,OAAOC,OAAO,GAAG,SAASC,IAAIC,iBAAiB,EAAEC,OAAO,EAAEC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IAC/EV,gBAAgBM,mBAAmBV,OAAO,CAAC,GAAGa,SAAS;QAAEf,MAAM;IAAM,IAAI,SAACiB,KAAKC;QAC7E,IAAID,KAAK,OAAOD,SAASC;QACzB,IAAI,CAACC,SAASC,MAAM,EAAE,OAAOH,SAAS,IAAII,MAAM,AAAC,sCAAuD,OAAlBR;QAEtF,IAAMS,eAAe,CAAC;QACtB,IAAK,IAAIC,IAAI,GAAGA,IAAId,UAAUW,MAAM,EAAEG,IAAK;YACzC,IAAIP,OAAO,CAACP,SAAS,CAACc,EAAE,CAAC,KAAKC,WAAWF,YAAY,CAACb,SAAS,CAACc,EAAE,CAAC,GAAGP,OAAO,CAACP,SAAS,CAACc,EAAE,CAAC;QAC7F;QAEA,IAAME,UAAU,EAAE;QAClB,IAAMC,QAAQ,IAAItB,MAAM;QACxB,IAAK,IAAIuB,QAAQ,GAAGA,QAAQR,SAASC,MAAM,EAAEO,QAAS;YACnD,CAAA,SAACC;gBACAF,MAAMG,KAAK,CAAC,SAACZ;oBACX,CAACD,QAAQc,MAAM,IAAId,QAAQc,MAAM,CAACF,QAAQA,OAAO,EAAEd,SAASC;oBAE5D,IAAMgB,mBAAmBf,QAAQe,gBAAgB,IAAIvB,UAAUuB,gBAAgB;oBAC/E,IAAMC,iBAAiBhB,QAAQgB,cAAc,IAAIxB,UAAUwB,cAAc;oBACzE,IAAMC,cAAchC,KAAKiC,IAAI,CAACH,kBAAkBH,QAAQA,OAAO;oBAE/DvB,eAAeuB,SAASK,aAAa;wBAAED,gBAAgBA;oBAAe,GAAG,SAACd;wBACxE,IAAIA,KAAK,OAAOD,SAASC;wBAEzBZ,aAAa6B,KAAK,CAACF,aAAanB,SAASC,MAAMO,cAAc,SAACJ,KAAKkB;4BACjEX,QAAQY,IAAI,CAAC;gCAAET,SAASA,QAAQA,OAAO;gCAAEU,OAAOpB;gCAAKqB,QAAQH;4BAAI;4BACjEnB;wBACF;oBACF;gBACF;YACF,CAAA,EAAGE,QAAQ,CAACQ,MAAM;QACpB;QACAD,MAAMc,KAAK,CAAC,SAACtB;YACXA,MAAMD,SAASC,OAAOD,SAAS,MAAMQ;QACvC;IACF;AACF"}
1
+ {"version":3,"sources":["use.js"],"sourcesContent":["const path = require('path');\nconst Queue = require('queue-cb');\nconst installRelease = require('node-install-release');\nconst versionUtils = require('node-version-utils');\nconst resolveVersions = require('node-resolve-versions');\n\nconst constants = require('./constants');\nconst spawnKeys = ['encoding', 'stdio', 'stdin', 'stdout', 'stderr', 'cwd', 'env'];\n\nmodule.exports = function use(versionExpression, command, args, options, callback) {\n resolveVersions(versionExpression, { ...options, path: 'raw' }, (err, versions) => {\n if (err) return callback(err);\n if (!versions.length) return callback(new Error(`No versions found from expression: ${versionExpression}`));\n\n const spawnOptions = {};\n for (let i = 0; i < spawnKeys.length; i++) {\n if (options[spawnKeys[i]] !== undefined) spawnOptions[spawnKeys[i]] = options[spawnKeys[i]];\n }\n\n const results = [];\n const queue = new Queue(1);\n for (let index = 0; index < versions.length; index++) {\n ((version) => {\n queue.defer((callback) => {\n !options.header || options.header(version.version, command, args);\n\n const installDirectory = options.installDirectory || constants.installDirectory;\n const cacheDirectory = options.cacheDirectory || constants.cacheDirectory;\n const installPath = path.join(installDirectory, version.version);\n\n installRelease(version, installPath, { cacheDirectory: cacheDirectory }, (err) => {\n if (err) return callback(err);\n\n versionUtils.spawn(installPath, command, args, spawnOptions, (err, res) => {\n results.push({ version: version.version, error: err, result: res });\n callback();\n });\n });\n });\n })(versions[index]);\n }\n queue.await((err) => {\n err ? callback(err) : callback(null, results);\n });\n });\n};\n"],"names":["path","require","Queue","installRelease","versionUtils","resolveVersions","constants","spawnKeys","module","exports","use","versionExpression","command","args","options","callback","err","versions","length","Error","spawnOptions","i","undefined","results","queue","index","version","defer","header","installDirectory","cacheDirectory","installPath","join","spawn","res","push","error","result","await"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAMA,OAAOC,QAAQ;AACrB,IAAMC,QAAQD,QAAQ;AACtB,IAAME,iBAAiBF,QAAQ;AAC/B,IAAMG,eAAeH,QAAQ;AAC7B,IAAMI,kBAAkBJ,QAAQ;AAEhC,IAAMK,YAAYL,QAAQ;AAC1B,IAAMM,YAAY;IAAC;IAAY;IAAS;IAAS;IAAU;IAAU;IAAO;CAAM;AAElFC,OAAOC,OAAO,GAAG,SAASC,I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ACF;gBACF;YACF,CAAA,EAAGE,QAAQ,CAACQ,MAAM;QACpB;QACAD,MAAMc,KAAK,CAAC,SAACtB;YACXA,MAAMD,SAASC,OAAOD,SAAS,MAAMQ;QACvC;IACF;AACF"}
@@ -0,0 +1,3 @@
1
+ export default function nodeVersionUse(versionExpression: any, command: any, args: any, options: any, callback: any): void | Promise<any>;
2
+ export function installDirectory(): string;
3
+ export function cacheDirectory(_options: any): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-version-use",
3
- "version": "0.4.8",
3
+ "version": "0.5.0",
4
4
  "description": "Cross-platform solution for using multiple versions of node. Useful for compatibility testing",
5
5
  "keywords": [
6
6
  "node",
@@ -17,11 +17,11 @@
17
17
  "url": "git@github.com:kmalakoff/node-version-use.git"
18
18
  },
19
19
  "license": "MIT",
20
+ "main": "dist/cjs/index.js",
21
+ "types": "dist/types/index.d.ts",
20
22
  "bin": {
21
23
  "nvu": "./bin/cli.js"
22
24
  },
23
- "main": "dist/cjs/index.js",
24
- "types": "dist/types/index.d.ts",
25
25
  "files": [
26
26
  "dist"
27
27
  ],
@@ -29,37 +29,35 @@
29
29
  "build": "tsds build",
30
30
  "deploy": "tsds deploy",
31
31
  "format": "biome check --apply-unsafe src/ test/",
32
- "test": "tsds test:node --timeout=1000000",
33
- "test:engines": "nvu engines tsds test:node --timeout=1000000",
32
+ "test": "tsds test:node --no-timeouts",
33
+ "test:engines": "nvu engines npm test",
34
34
  "version": "tsds version"
35
35
  },
36
36
  "dependencies": {
37
- "cross-spawn-cb": "^0.6.17",
37
+ "cross-spawn-cb": "^0.6.18",
38
38
  "exit": "^0.1.2",
39
39
  "getopts-compat": "^2.2.5",
40
- "just-extend": "^6.2.0",
41
- "node-install-release": "^0.4.8",
42
- "node-resolve-versions": "^0.3.9",
40
+ "node-install-release": "^1.1.1",
41
+ "node-resolve-versions": "^0.3.10",
43
42
  "node-version-utils": "^0.5.6",
44
43
  "osenv": "^0.1.5",
45
- "queue-cb": "^1.1.7"
44
+ "queue-cb": "^1.2.1"
46
45
  },
47
46
  "devDependencies": {
48
47
  "@biomejs/biome": "^1.5.3",
49
48
  "@types/mocha": "^10.0.6",
50
- "@types/node": "^20.11.17",
49
+ "@types/node": "^20.11.19",
51
50
  "cr": "^0.1.0",
52
51
  "depcheck": "^1.4.7",
53
52
  "is-version": "^0.2.1",
54
- "node-version-use": "^0.4.7",
55
53
  "rimraf": "^2.7.1",
56
- "ts-dev-stack": "^0.9.7"
54
+ "ts-dev-stack": "^0.14.9"
57
55
  },
58
56
  "engines": {
59
57
  "node": ">=0.8"
60
58
  },
61
59
  "tsds": {
62
- "source": "src/index.js",
60
+ "source": "src/index.mjs",
63
61
  "targets": [
64
62
  "cjs"
65
63
  ]
@@ -1,6 +0,0 @@
1
- declare function _exports(versionExpression: any, command: any, args: any, options: any, callback: any): void | Promise<any>;
2
- declare namespace _exports {
3
- function installDirectory(): string;
4
- function cacheDirectory(_options: any): string;
5
- }
6
- export = _exports;