node-version-utils 0.3.1 → 0.4.2
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 +5 -0
- package/lib/spawnOptions.js +12 -17
- package/lib/startsCaseInsensitiveFn.js +11 -0
- package/package.json +16 -18
- package/.github/dependabot.yml +0 -11
- package/.github/workflows/main.yml +0 -22
- package/index.js +0 -4
package/lib/index.js
ADDED
package/lib/spawnOptions.js
CHANGED
|
@@ -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
|
|
5
|
+
var pathKey = require('cross-spawn-cb/lib/path-key').default;
|
|
6
|
+
var startsCaseInsensitiveFn = require('./startsCaseInsensitiveFn');
|
|
6
7
|
|
|
7
8
|
var isWindows = process.platform === 'win32';
|
|
8
9
|
|
|
9
|
-
|
|
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,27 +22,17 @@ 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
|
|
22
|
-
|
|
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
|
|
|
37
31
|
// override node
|
|
38
32
|
if (env.NODE !== undefined) env.NODE = env.npm_node_execpath;
|
|
33
|
+
if (env.NODE_EXE !== undefined) env.NODE_EXE = env.npm_node_execpath;
|
|
39
34
|
|
|
40
35
|
// put the path to node and npm at the front and remove nvs
|
|
41
36
|
env[PATH_KEY] = prepend(env[PATH_KEY] || '', env.npm_config_binroot);
|
|
42
|
-
return assign({}, options, { cwd: process.cwd(), env: env
|
|
37
|
+
return assign({}, options, { cwd: process.cwd(), env: env });
|
|
43
38
|
};
|
|
@@ -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
|
+
"version": "0.4.2",
|
|
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,41 @@
|
|
|
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.5.
|
|
32
|
-
"env-path-key": "^0.2.0",
|
|
33
|
+
"cross-spawn-cb": "^0.5.12",
|
|
33
34
|
"just-extend": "^6.0.1",
|
|
34
35
|
"path-string-prepend": "^0.2.0"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
|
-
"@typescript-eslint/parser": "^5.30.
|
|
38
|
+
"@typescript-eslint/parser": "^5.30.5",
|
|
38
39
|
"cr": "^0.1.0",
|
|
39
40
|
"depcheck": "^1.4.3",
|
|
40
|
-
"dis-dat": "^0.1.
|
|
41
|
-
"eslint": "^
|
|
42
|
-
"eslint-config-prettier": "^
|
|
43
|
-
"eslint-config-standard": "^
|
|
44
|
-
"eslint-plugin-import": "^2.
|
|
45
|
-
"eslint-plugin-
|
|
46
|
-
"eslint-plugin-promise": "^4.2.1",
|
|
47
|
-
"eslint-plugin-standard": "^4.0.1",
|
|
41
|
+
"dis-dat": "^0.1.7",
|
|
42
|
+
"eslint": "^8.19.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.
|
|
53
|
-
"node-version-use": "^0.2.2",
|
|
51
|
+
"node-install-release": "^0.2.8",
|
|
54
52
|
"prettier": "^2.7.1",
|
|
55
53
|
"rimraf": "^2.7.1",
|
|
56
54
|
"semver": "^5.7.1"
|
|
57
55
|
},
|
|
58
56
|
"engines": {
|
|
59
|
-
"node": ">=0.
|
|
57
|
+
"node": ">=0.8"
|
|
60
58
|
}
|
|
61
59
|
}
|
package/.github/dependabot.yml
DELETED
|
@@ -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