node-version-use 0.2.4 → 0.2.7

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/lib/cli.js CHANGED
@@ -27,6 +27,7 @@ module.exports = function cli(argv, name) {
27
27
  console.log('----------------------');
28
28
  };
29
29
 
30
+ options.stdio = 'inherit'; // pass through stdio
30
31
  nvs(args[0], args[1], args.slice(2), options, function (err, results) {
31
32
  if (err) {
32
33
  console.log(err.message);
@@ -0,0 +1,7 @@
1
+ var path = require('path');
2
+ var home = require('osenv').home();
3
+
4
+ module.exports = {
5
+ cacheDirectory: path.join(home, '.nvu', 'cache'),
6
+ installDirectory: path.join(home, '.nvu', 'installed'),
7
+ };
package/lib/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  var use = require('./use');
2
+ var constants = require('./constants');
2
3
 
3
4
  module.exports = function nodeVersionUse(versionExpression, command, args, options, callback) {
4
5
  if (typeof options === 'function') {
@@ -12,3 +13,11 @@ module.exports = function nodeVersionUse(versionExpression, command, args, optio
12
13
  });
13
14
  });
14
15
  };
16
+
17
+ module.exports.installDirectory = function installDirectory() {
18
+ return constants.installDirectory;
19
+ };
20
+
21
+ module.exports.cacheDirectory = function cacheDirectory(options) {
22
+ return constants.cacheDirectory;
23
+ };
package/lib/use.js CHANGED
@@ -5,19 +5,18 @@ var installRelease = require('node-install-release');
5
5
  var versionUtils = require('node-version-utils');
6
6
  var resolveVersions = require('node-resolve-versions');
7
7
 
8
- var HOME = require('osenv').home();
9
- var DEFAULT_OPTIONS = {
10
- cacheDirectory: path.join(HOME, '.nvu', 'cache'),
11
- installedDirectory: path.join(HOME, '.nvu', 'installed'),
12
- };
8
+ var constants = require('./constants');
9
+ var spawnKeys = ['encoding', 'stdio', 'stdin', 'stdout', 'stderr', 'cwd', 'env'];
13
10
 
14
11
  module.exports = function use(versionExpression, command, args, options, callback) {
15
12
  resolveVersions(versionExpression, assign({}, options, { path: 'raw' }), function (err, versions) {
16
13
  if (err) return callback(err);
17
14
  if (!versions.length) return callback(new Error('No versions found from expression: ' + versionExpression));
18
15
 
19
- var spawnOptions = assign({}, options);
20
- if (!spawnOptions.stdout && !spawnOptions.stdio) spawnOptions.stdio = 'inherit';
16
+ var spawnOptions = {};
17
+ for (var i = 0; i < spawnKeys.length; i++) {
18
+ if (options[spawnKeys[i]] !== undefined) spawnOptions[spawnKeys[i]] = options[spawnKeys[i]];
19
+ }
21
20
 
22
21
  var results = [];
23
22
  var queue = new Queue(1);
@@ -26,9 +25,9 @@ module.exports = function use(versionExpression, command, args, options, callbac
26
25
  queue.defer(function (callback) {
27
26
  !options.header || options.header(version.version, command, args);
28
27
 
29
- var installedDirectory = options.installedDirectory || DEFAULT_OPTIONS.installedDirectory;
30
- var cacheDirectory = options.cacheDirectory || DEFAULT_OPTIONS.cacheDirectory;
31
- var installPath = path.join(installedDirectory, version.version);
28
+ var installDirectory = options.installDirectory || constants.installDirectory;
29
+ var cacheDirectory = options.cacheDirectory || constants.cacheDirectory;
30
+ var installPath = path.join(installDirectory, version.version);
32
31
 
33
32
  installRelease(version, installPath, { cacheDirectory: cacheDirectory }, function (err) {
34
33
  if (err) return callback(err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-version-use",
3
- "version": "0.2.4",
3
+ "version": "0.2.7",
4
4
  "description": "Cross-platform solution for using multiple versions of node. Useful for compatibility testing",
5
5
  "keywords": [
6
6
  "node",
@@ -28,26 +28,25 @@
28
28
  "compat": "./bin/node-version-use.js engines mocha-compat test/spec/**/*.test.js --no-timeouts",
29
29
  "format": "prettier --write .",
30
30
  "lint": "eslint .",
31
- "prepublishOnly": "dtd \"npm run lint\" \"depcheck\"",
31
+ "prepublishOnly": "npm run lint && depcheck",
32
32
  "test": "mocha-compat test/spec/**/*.test.js --no-timeouts"
33
33
  },
34
34
  "dependencies": {
35
- "cross-spawn-cb": "^0.5.9",
35
+ "cross-spawn-cb": "^0.6.3",
36
36
  "exit": "^0.1.2",
37
37
  "getopts-compat": "^2.2.5",
38
38
  "just-extend": "^6.0.1",
39
- "node-install-release": "^0.2.5",
40
- "node-resolve-versions": "^0.2.2",
41
- "node-version-utils": "^0.4.0",
39
+ "node-install-release": "^0.2.8",
40
+ "node-resolve-versions": "^0.2.5",
41
+ "node-version-utils": "^0.4.4",
42
42
  "osenv": "^0.1.5",
43
43
  "queue-cb": "^1.1.6"
44
44
  },
45
45
  "devDependencies": {
46
- "@typescript-eslint/parser": "^5.30.0",
46
+ "@typescript-eslint/parser": "^5.30.7",
47
47
  "cr": "^0.1.0",
48
48
  "depcheck": "^1.4.3",
49
- "dis-dat": "^0.1.6",
50
- "eslint": "^8.18.0",
49
+ "eslint": "^8.20.0",
51
50
  "eslint-config-prettier": "^8.5.0",
52
51
  "eslint-config-standard": "^17.0.0",
53
52
  "eslint-plugin-import": "^2.26.0",