node-version-utils 1.3.10 → 1.3.12
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/spawnOptions.js
CHANGED
|
@@ -84,7 +84,7 @@ function spawnOptions(installPath) {
|
|
|
84
84
|
// Keep original path if resolution fails
|
|
85
85
|
}
|
|
86
86
|
var PATH_KEY = (0, _envpathkey.default)();
|
|
87
|
-
var processEnv = process.env;
|
|
87
|
+
var processEnv = options.env || process.env;
|
|
88
88
|
var bin = isWindows ? installPath : _path.default.join(installPath, 'bin');
|
|
89
89
|
var env = {};
|
|
90
90
|
env.npm_node_execpath = _path.default.join(bin, NODE);
|
|
@@ -99,8 +99,12 @@ function spawnOptions(installPath) {
|
|
|
99
99
|
// override node
|
|
100
100
|
if (env.NODE !== undefined) env.NODE = env.npm_node_execpath;
|
|
101
101
|
if (env.NODE_EXE !== undefined) env.NODE_EXE = env.npm_node_execpath;
|
|
102
|
-
// put the path to node and npm at the front
|
|
103
|
-
env[PATH_KEY]
|
|
102
|
+
// put the path to node and npm at the front, fallback to process.env PATH if missing
|
|
103
|
+
var basePath = env[PATH_KEY] || process.env[PATH_KEY] || '';
|
|
104
|
+
if (options.env && !options.env[PATH_KEY]) {
|
|
105
|
+
console.warn("node-version-utils: options.env missing ".concat(PATH_KEY, ", falling back to process.env.").concat(PATH_KEY));
|
|
106
|
+
}
|
|
107
|
+
env[PATH_KEY] = (0, _pathstringprepend.default)(basePath, bin);
|
|
104
108
|
return _object_spread_props(_object_spread({}, options), {
|
|
105
109
|
cwd: process.cwd(),
|
|
106
110
|
env: env
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-utils/src/spawnOptions.ts"],"sourcesContent":["import pathKey from 'env-path-key';\nimport fs from 'fs';\nimport path from 'path';\nimport prepend from 'path-string-prepend';\nimport startsWithFn from './lib/startsWithFn.ts';\n\nconst isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE);\nconst NODE = isWindows ? 'node.exe' : 'node';\n\nconst startsNPM = startsWithFn('npm_');\nconst startsPath = startsWithFn('path');\n\nimport type { ProcessEnv, SpawnOptions } from './types.ts';\n\nexport default function spawnOptions(installPath: string, options: SpawnOptions = {}): SpawnOptions {\n // Resolve symlinks to get real path (fixes nvm-windows symlink issues where\n // C:\\nvm4w\\nodejs points to the active Node version via symlink)\n try {\n installPath = fs.realpathSync(installPath);\n } catch (_e) {\n // Keep original path if resolution fails\n }\n\n const PATH_KEY = pathKey();\n const processEnv = process.env;\n const bin = isWindows ? installPath : path.join(installPath, 'bin');\n const env = {} as ProcessEnv;\n env.npm_node_execpath = path.join(bin, NODE);\n env.npm_config_prefix = installPath;\n\n // copy the environment not for npm and skip case-insesitive additional paths\n for (const key in processEnv) {\n // skip npm_ variants and non-matching path\n if (key.length > 4 && startsNPM(key)) continue;\n if (key.length === 4 && startsPath(key) && key !== PATH_KEY) continue;\n env[key] = processEnv[key];\n }\n\n // override node\n if (env.NODE !== undefined) env.NODE = env.npm_node_execpath;\n if (env.NODE_EXE !== undefined) env.NODE_EXE = env.npm_node_execpath;\n\n // put the path to node and npm at the front
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-utils/src/spawnOptions.ts"],"sourcesContent":["import pathKey from 'env-path-key';\nimport fs from 'fs';\nimport path from 'path';\nimport prepend from 'path-string-prepend';\nimport startsWithFn from './lib/startsWithFn.ts';\n\nconst isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE);\nconst NODE = isWindows ? 'node.exe' : 'node';\n\nconst startsNPM = startsWithFn('npm_');\nconst startsPath = startsWithFn('path');\n\nimport type { ProcessEnv, SpawnOptions } from './types.ts';\n\nexport default function spawnOptions(installPath: string, options: SpawnOptions = {}): SpawnOptions {\n // Resolve symlinks to get real path (fixes nvm-windows symlink issues where\n // C:\\nvm4w\\nodejs points to the active Node version via symlink)\n try {\n installPath = fs.realpathSync(installPath);\n } catch (_e) {\n // Keep original path if resolution fails\n }\n\n const PATH_KEY = pathKey();\n const processEnv = options.env || process.env;\n const bin = isWindows ? installPath : path.join(installPath, 'bin');\n const env = {} as ProcessEnv;\n env.npm_node_execpath = path.join(bin, NODE);\n env.npm_config_prefix = installPath;\n\n // copy the environment not for npm and skip case-insesitive additional paths\n for (const key in processEnv) {\n // skip npm_ variants and non-matching path\n if (key.length > 4 && startsNPM(key)) continue;\n if (key.length === 4 && startsPath(key) && key !== PATH_KEY) continue;\n env[key] = processEnv[key];\n }\n\n // override node\n if (env.NODE !== undefined) env.NODE = env.npm_node_execpath;\n if (env.NODE_EXE !== undefined) env.NODE_EXE = env.npm_node_execpath;\n\n // put the path to node and npm at the front, fallback to process.env PATH if missing\n const basePath = env[PATH_KEY] || process.env[PATH_KEY] || '';\n if (options.env && !options.env[PATH_KEY]) {\n console.warn(`node-version-utils: options.env missing ${PATH_KEY}, falling back to process.env.${PATH_KEY}`);\n }\n env[PATH_KEY] = prepend(basePath, bin) as string;\n return { ...options, cwd: process.cwd(), env } as SpawnOptions;\n}\n"],"names":["spawnOptions","isWindows","process","platform","test","env","OSTYPE","NODE","startsNPM","startsWithFn","startsPath","installPath","options","fs","realpathSync","_e","PATH_KEY","pathKey","processEnv","bin","path","join","npm_node_execpath","npm_config_prefix","key","length","undefined","NODE_EXE","basePath","console","warn","prepend","cwd"],"mappings":";;;;+BAcA;;;eAAwBA;;;iEAdJ;yDACL;2DACE;wEACG;qEACK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEzB,IAAMC,YAAYC,QAAQC,QAAQ,KAAK,WAAW,kBAAkBC,IAAI,CAACF,QAAQG,GAAG,CAACC,MAAM;AAC3F,IAAMC,OAAON,YAAY,aAAa;AAEtC,IAAMO,YAAYC,IAAAA,uBAAY,EAAC;AAC/B,IAAMC,aAAaD,IAAAA,uBAAY,EAAC;AAI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GAAG;QAAI3B,KAAAA;;AAC3C"}
|
package/dist/esm/spawnOptions.js
CHANGED
|
@@ -16,7 +16,7 @@ export default function spawnOptions(installPath, options = {}) {
|
|
|
16
16
|
// Keep original path if resolution fails
|
|
17
17
|
}
|
|
18
18
|
const PATH_KEY = pathKey();
|
|
19
|
-
const processEnv = process.env;
|
|
19
|
+
const processEnv = options.env || process.env;
|
|
20
20
|
const bin = isWindows ? installPath : path.join(installPath, 'bin');
|
|
21
21
|
const env = {};
|
|
22
22
|
env.npm_node_execpath = path.join(bin, NODE);
|
|
@@ -31,8 +31,12 @@ export default function spawnOptions(installPath, options = {}) {
|
|
|
31
31
|
// override node
|
|
32
32
|
if (env.NODE !== undefined) env.NODE = env.npm_node_execpath;
|
|
33
33
|
if (env.NODE_EXE !== undefined) env.NODE_EXE = env.npm_node_execpath;
|
|
34
|
-
// put the path to node and npm at the front
|
|
35
|
-
env[PATH_KEY]
|
|
34
|
+
// put the path to node and npm at the front, fallback to process.env PATH if missing
|
|
35
|
+
const basePath = env[PATH_KEY] || process.env[PATH_KEY] || '';
|
|
36
|
+
if (options.env && !options.env[PATH_KEY]) {
|
|
37
|
+
console.warn(`node-version-utils: options.env missing ${PATH_KEY}, falling back to process.env.${PATH_KEY}`);
|
|
38
|
+
}
|
|
39
|
+
env[PATH_KEY] = prepend(basePath, bin);
|
|
36
40
|
return {
|
|
37
41
|
...options,
|
|
38
42
|
cwd: process.cwd(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-utils/src/spawnOptions.ts"],"sourcesContent":["import pathKey from 'env-path-key';\nimport fs from 'fs';\nimport path from 'path';\nimport prepend from 'path-string-prepend';\nimport startsWithFn from './lib/startsWithFn.ts';\n\nconst isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE);\nconst NODE = isWindows ? 'node.exe' : 'node';\n\nconst startsNPM = startsWithFn('npm_');\nconst startsPath = startsWithFn('path');\n\nimport type { ProcessEnv, SpawnOptions } from './types.ts';\n\nexport default function spawnOptions(installPath: string, options: SpawnOptions = {}): SpawnOptions {\n // Resolve symlinks to get real path (fixes nvm-windows symlink issues where\n // C:\\nvm4w\\nodejs points to the active Node version via symlink)\n try {\n installPath = fs.realpathSync(installPath);\n } catch (_e) {\n // Keep original path if resolution fails\n }\n\n const PATH_KEY = pathKey();\n const processEnv = process.env;\n const bin = isWindows ? installPath : path.join(installPath, 'bin');\n const env = {} as ProcessEnv;\n env.npm_node_execpath = path.join(bin, NODE);\n env.npm_config_prefix = installPath;\n\n // copy the environment not for npm and skip case-insesitive additional paths\n for (const key in processEnv) {\n // skip npm_ variants and non-matching path\n if (key.length > 4 && startsNPM(key)) continue;\n if (key.length === 4 && startsPath(key) && key !== PATH_KEY) continue;\n env[key] = processEnv[key];\n }\n\n // override node\n if (env.NODE !== undefined) env.NODE = env.npm_node_execpath;\n if (env.NODE_EXE !== undefined) env.NODE_EXE = env.npm_node_execpath;\n\n // put the path to node and npm at the front
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-utils/src/spawnOptions.ts"],"sourcesContent":["import pathKey from 'env-path-key';\nimport fs from 'fs';\nimport path from 'path';\nimport prepend from 'path-string-prepend';\nimport startsWithFn from './lib/startsWithFn.ts';\n\nconst isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE);\nconst NODE = isWindows ? 'node.exe' : 'node';\n\nconst startsNPM = startsWithFn('npm_');\nconst startsPath = startsWithFn('path');\n\nimport type { ProcessEnv, SpawnOptions } from './types.ts';\n\nexport default function spawnOptions(installPath: string, options: SpawnOptions = {}): SpawnOptions {\n // Resolve symlinks to get real path (fixes nvm-windows symlink issues where\n // C:\\nvm4w\\nodejs points to the active Node version via symlink)\n try {\n installPath = fs.realpathSync(installPath);\n } catch (_e) {\n // Keep original path if resolution fails\n }\n\n const PATH_KEY = pathKey();\n const processEnv = options.env || process.env;\n const bin = isWindows ? installPath : path.join(installPath, 'bin');\n const env = {} as ProcessEnv;\n env.npm_node_execpath = path.join(bin, NODE);\n env.npm_config_prefix = installPath;\n\n // copy the environment not for npm and skip case-insesitive additional paths\n for (const key in processEnv) {\n // skip npm_ variants and non-matching path\n if (key.length > 4 && startsNPM(key)) continue;\n if (key.length === 4 && startsPath(key) && key !== PATH_KEY) continue;\n env[key] = processEnv[key];\n }\n\n // override node\n if (env.NODE !== undefined) env.NODE = env.npm_node_execpath;\n if (env.NODE_EXE !== undefined) env.NODE_EXE = env.npm_node_execpath;\n\n // put the path to node and npm at the front, fallback to process.env PATH if missing\n const basePath = env[PATH_KEY] || process.env[PATH_KEY] || '';\n if (options.env && !options.env[PATH_KEY]) {\n console.warn(`node-version-utils: options.env missing ${PATH_KEY}, falling back to process.env.${PATH_KEY}`);\n }\n env[PATH_KEY] = prepend(basePath, bin) as string;\n return { ...options, cwd: process.cwd(), env } as SpawnOptions;\n}\n"],"names":["pathKey","fs","path","prepend","startsWithFn","isWindows","process","platform","test","env","OSTYPE","NODE","startsNPM","startsPath","spawnOptions","installPath","options","realpathSync","_e","PATH_KEY","processEnv","bin","join","npm_node_execpath","npm_config_prefix","key","length","undefined","NODE_EXE","basePath","console","warn","cwd"],"mappings":"AAAA,OAAOA,aAAa,eAAe;AACnC,OAAOC,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AACxB,OAAOC,aAAa,sBAAsB;AAC1C,OAAOC,kBAAkB,wBAAwB;AAEjD,MAAMC,YAAYC,QAAQC,QAAQ,KAAK,WAAW,kBAAkBC,IAAI,CAACF,QAAQG,GAAG,CAACC,MAAM;AAC3F,MAAMC,OAAON,YAAY,aAAa;AAEtC,MAAMO,YAAYR,aAAa;AAC/B,MAAMS,aAAaT,aAAa;AAIhC,eAAe,SAASU,aAAaC,WAAmB,EAAEC,UAAwB,CAAC,CAAC;IAClF,4EAA4E;IAC5E,iEAAiE;IACjE,IAAI;QACFD,cAAcd,GAAGgB,YAAY,CAACF;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1.3.12",
|
|
4
4
|
"description": "Utilities for running commands on a specific version of node by installed path",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
],
|
|
36
36
|
"scripts": {
|
|
37
37
|
"build": "tsds build",
|
|
38
|
-
"format": "
|
|
38
|
+
"format": "tsds format",
|
|
39
39
|
"prepublishOnly": "tsds validate",
|
|
40
40
|
"test": "tsds test:node --no-timeouts",
|
|
41
41
|
"test:engines": "nvu engines tsds test:node --no-timeouts",
|
|
@@ -46,7 +46,6 @@
|
|
|
46
46
|
"path-string-prepend": "*"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@biomejs/biome": "*",
|
|
50
49
|
"@types/mocha": "*",
|
|
51
50
|
"@types/node": "*",
|
|
52
51
|
"cr": "*",
|
|
@@ -56,7 +55,8 @@
|
|
|
56
55
|
"node-resolve-versions": "*",
|
|
57
56
|
"node-version-use": "*",
|
|
58
57
|
"rimraf2": "*",
|
|
59
|
-
"ts-dev-stack": "*"
|
|
58
|
+
"ts-dev-stack": "*",
|
|
59
|
+
"tsds-config": "*"
|
|
60
60
|
},
|
|
61
61
|
"engines": {
|
|
62
62
|
"node": ">=0.8"
|