node-version-utils 0.3.1 → 0.4.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/.eslintrc.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "extends": ["standard", "prettier"],
3
+ "parser": "@typescript-eslint/parser",
4
+ "env": {
5
+ "es6": true,
6
+ "node": true,
7
+ "mocha": true
8
+ },
9
+ "rules": {
10
+ "no-var": "off",
11
+ "object-shorthand": "off"
12
+ }
13
+ }
@@ -17,6 +17,7 @@ jobs:
17
17
  node-version: ${{ matrix.node-version }}
18
18
  - run: git config --global user.name "Github Actions"
19
19
  - run: git config --global user.email "actions@users.noreply.github.com"
20
+ - run: npm install node-version-use -g
20
21
  - run: npm ci
21
22
  - run: npm run lint
22
- - run: npm run test:engines
23
+ - run: nvu engines --desc npm run test
@@ -2,11 +2,16 @@ var path = require('path');
2
2
  var assign = require('just-extend');
3
3
  var prepend = require('path-string-prepend');
4
4
  var NODE = process.platform === 'win32' ? 'node.exe' : 'node';
5
- var PATH_KEY = require('env-path-key')();
5
+ var pathKey = require('cross-spawn-cb').pathKey;
6
+ var startsCaseInsensitiveFn = require('./startsCaseInsensitiveFn');
6
7
 
7
8
  var isWindows = process.platform === 'win32';
8
9
 
9
- module.exports = function envForInstallPath(installPath, options) {
10
+ var startsNPM = startsCaseInsensitiveFn('npm_');
11
+ var startsPath = startsCaseInsensitiveFn('path');
12
+
13
+ module.exports = function spawnOptions(installPath, options) {
14
+ var PATH_KEY = pathKey();
10
15
  var processEnv = process.env;
11
16
  var env = {};
12
17
  env.npm_config_binroot = isWindows ? installPath : path.join(installPath, 'bin');
@@ -17,20 +22,9 @@ module.exports = function envForInstallPath(installPath, options) {
17
22
 
18
23
  // copy the environment not for npm and skip case-insesitive additional paths
19
24
  for (var key in processEnv) {
20
- // skip npm_ variants
21
- if (key.length > 4 && (key[0] === 'n' || key[0] === 'N') && (key[1] === 'p' || key[1] === 'P') && (key[2] === 'm' || key[2] === 'M') && key[3] === '_')
22
- continue;
23
-
24
- // skip non-matching path
25
- if (
26
- key.length === 4 &&
27
- (key[0] === 'p' || key[0] === 'P') &&
28
- (key[1] === 'a' || key[1] === 'A') &&
29
- (key[2] === 't' || key[2] === 'T') &&
30
- (key[3] === 'h' || key[3] === 'H') &&
31
- key !== PATH_KEY
32
- )
33
- continue;
25
+ // skip npm_ variants and non-matching path
26
+ if (key.length > 4 && startsNPM(key)) continue;
27
+ if (key.length === 4 && startsPath(key) && key !== PATH_KEY) continue;
34
28
  env[key] = processEnv[key];
35
29
  }
36
30
 
@@ -0,0 +1,11 @@
1
+ module.exports = function startsCaseInsensitiveFn(string) {
2
+ var lower = string.toLowerCase();
3
+ var upper = string.toUpperCase();
4
+ return function startsCaseInsensitive(key) {
5
+ if (key.length < string.length) return false;
6
+ for (var i = 0; i < string.length; i++) {
7
+ if (key[i] !== lower[i] && key[i] !== upper[i]) return false;
8
+ }
9
+ return true;
10
+ };
11
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-version-utils",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "description": "Utilities for running commands on a specific version of node by installed path",
5
5
  "keywords": [
6
6
  "node",
@@ -24,12 +24,10 @@
24
24
  "format": "prettier --write .",
25
25
  "lint": "eslint .",
26
26
  "prepublishOnly": "dtd \"npm run lint\" \"depcheck\"",
27
- "test": "mocha-compat test/spec/**/*.test.js --no-timeouts",
28
- "test:engines": "nvu engines npm test"
27
+ "test": "mocha-compat test/spec/**/*.test.js --no-timeouts"
29
28
  },
30
29
  "dependencies": {
31
- "cross-spawn-cb": "^0.5.2",
32
- "env-path-key": "^0.2.0",
30
+ "cross-spawn-cb": "^0.5.9",
33
31
  "just-extend": "^6.0.1",
34
32
  "path-string-prepend": "^0.2.0"
35
33
  },
@@ -37,25 +35,22 @@
37
35
  "@typescript-eslint/parser": "^5.30.0",
38
36
  "cr": "^0.1.0",
39
37
  "depcheck": "^1.4.3",
40
- "dis-dat": "^0.1.5",
41
- "eslint": "^6.8.0",
42
- "eslint-config-prettier": "^6.11.0",
43
- "eslint-config-standard": "^14.1.1",
44
- "eslint-plugin-import": "^2.22.0",
38
+ "dis-dat": "^0.1.6",
39
+ "eslint": "^8.18.0",
40
+ "eslint-config-prettier": "^8.5.0",
41
+ "eslint-config-standard": "^17.0.0",
42
+ "eslint-plugin-import": "^2.26.0",
45
43
  "eslint-plugin-node": "^11.1.0",
46
- "eslint-plugin-promise": "^4.2.1",
47
- "eslint-plugin-standard": "^4.0.1",
44
+ "eslint-plugin-promise": "^6.0.0",
48
45
  "is-version": "^0.2.0",
49
46
  "lodash.find": "^4.6.0",
50
47
  "match-semver": "^0.1.0",
51
48
  "mocha-compat": "^3.5.5",
52
- "node-install-release": "^0.2.4",
53
- "node-version-use": "^0.2.2",
49
+ "node-install-release": "^0.2.5",
54
50
  "prettier": "^2.7.1",
55
- "rimraf": "^2.7.1",
56
51
  "semver": "^5.7.1"
57
52
  },
58
53
  "engines": {
59
- "node": ">=0.10"
54
+ "node": ">=0.8"
60
55
  }
61
56
  }