node-version-utils 0.3.0 → 0.4.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.
package/lib/index.js ADDED
@@ -0,0 +1,4 @@
1
+ module.exports = {
2
+ spawn: require('./spawn'),
3
+ spawnSync: require('./spawnSync'),
4
+ };
@@ -1,12 +1,17 @@
1
1
  var path = require('path');
2
- var assign = require('object-assign');
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,18 +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] === '_')) continue;;
22
-
23
- // skip non-matching path
24
- if (
25
- key.length === 4 &&
26
- (key[0] === 'p' || key[0] === 'P') &&
27
- (key[1] === 'a' || key[1] === 'A') &&
28
- (key[2] === 't' || key[2] === 'T') &&
29
- (key[3] === 'h' || key[3] === 'H') &&
30
- key !== PATH_KEY
31
- ) 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;
32
28
  env[key] = processEnv[key];
33
29
  }
34
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.0",
3
+ "version": "0.4.1",
4
4
  "description": "Utilities for running commands on a specific version of node by installed path",
5
5
  "keywords": [
6
6
  "node",
@@ -19,43 +19,40 @@
19
19
  "url": "git@github.com:kmalakoff/node-version-utils.git"
20
20
  },
21
21
  "license": "MIT",
22
- "main": "index.js",
22
+ "main": "lib/index.js",
23
+ "files": [
24
+ "lib"
25
+ ],
23
26
  "scripts": {
24
27
  "format": "prettier --write .",
25
28
  "lint": "eslint .",
26
29
  "prepublishOnly": "dtd \"npm run lint\" \"depcheck\"",
27
- "test": "mocha-compat test/spec/**/*.test.js --no-timeouts",
28
- "test:engines": "nvu engines npm test"
30
+ "test": "mocha-compat test/spec/**/*.test.js --no-timeouts"
29
31
  },
30
32
  "dependencies": {
31
- "cross-spawn-cb": "^0.4.1",
32
- "env-path-key": "^0.1.0",
33
- "object-assign": "^4.1.1",
33
+ "cross-spawn-cb": "^0.5.9",
34
+ "just-extend": "^6.0.1",
34
35
  "path-string-prepend": "^0.2.0"
35
36
  },
36
37
  "devDependencies": {
37
- "babel-eslint": "^10.1.0",
38
+ "@typescript-eslint/parser": "^5.30.0",
38
39
  "cr": "^0.1.0",
39
- "depcheck": "^1.4.2",
40
- "dis-dat": "^0.1.3",
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",
45
- "eslint-plugin-node": "^11.1.0",
46
- "eslint-plugin-promise": "^4.2.1",
47
- "eslint-plugin-standard": "^4.0.1",
40
+ "depcheck": "^1.4.3",
41
+ "dis-dat": "^0.1.6",
42
+ "eslint": "^8.18.0",
43
+ "eslint-config-prettier": "^8.5.0",
44
+ "eslint-config-standard": "^17.0.0",
45
+ "eslint-plugin-import": "^2.26.0",
46
+ "eslint-plugin-promise": "^6.0.0",
48
47
  "is-version": "^0.2.0",
49
48
  "lodash.find": "^4.6.0",
50
49
  "match-semver": "^0.1.0",
51
50
  "mocha-compat": "^3.5.5",
52
- "node-install-release": "^0.2.2",
53
- "node-version-use": "^0.2.0",
54
- "prettier": "^2.4.1",
55
- "rimraf": "^2.7.1",
51
+ "node-install-release": "^0.2.6",
52
+ "prettier": "^2.7.1",
56
53
  "semver": "^5.7.1"
57
54
  },
58
55
  "engines": {
59
- "node": ">=0.10"
56
+ "node": ">=0.8"
60
57
  }
61
58
  }
@@ -1,11 +0,0 @@
1
- version: 2
2
- updates:
3
- - package-ecosystem: npm
4
- directory: '/'
5
- schedule:
6
- interval: daily
7
- - package-ecosystem: 'github-actions'
8
- directory: '/'
9
- schedule:
10
- # Check for updates to GitHub Actions every weekday
11
- interval: 'daily'
@@ -1,22 +0,0 @@
1
- name: CI
2
- on:
3
- - push
4
- - pull_request
5
- jobs:
6
- test:
7
- name: Node.js ${{ matrix.node-version }} ${{ matrix.os }}
8
- runs-on: ${{ matrix.os }}
9
- strategy:
10
- matrix:
11
- node: ['latest']
12
- os: [ubuntu-latest, windows-latest, macOS-latest]
13
- steps:
14
- - uses: actions/checkout@v2
15
- - uses: actions/setup-node@v2.4.1
16
- with:
17
- node-version: ${{ matrix.node-version }}
18
- - run: git config --global user.name "Github Actions"
19
- - run: git config --global user.email "actions@users.noreply.github.com"
20
- - run: npm ci
21
- - run: npm run lint
22
- - run: npm run test:engines
package/index.js DELETED
@@ -1,4 +0,0 @@
1
- module.exports = {
2
- spawn: require('./lib/spawn'),
3
- spawnSync: require('./lib/spawnSync'),
4
- };