node-version-call-local
Advanced tools
| export type ResolvedVersion = { | ||
| execPath: string; | ||
| installPath: string; | ||
| }; | ||
| export type ResolveOptions = { | ||
| env?: NodeJS.ProcessEnv; | ||
| }; | ||
| export default function resolveVersion(version: string, options?: ResolveOptions): ResolvedVersion; |
| export type ResolvedVersion = { | ||
| execPath: string; | ||
| installPath: string; | ||
| }; | ||
| export type ResolveOptions = { | ||
| env?: NodeJS.ProcessEnv; | ||
| }; | ||
| export default function resolveVersion(version: string, options?: ResolveOptions): ResolvedVersion; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| Object.defineProperty(exports, "default", { | ||
| enumerable: true, | ||
| get: function() { | ||
| return resolveVersion; | ||
| } | ||
| }); | ||
| var _module = /*#__PURE__*/ _interop_require_default(require("module")); | ||
| var _path = /*#__PURE__*/ _interop_require_default(require("path")); | ||
| function _interop_require_default(obj) { | ||
| return obj && obj.__esModule ? obj : { | ||
| default: obj | ||
| }; | ||
| } | ||
| var _require = typeof require === 'undefined' ? _module.default.createRequire(require("url").pathToFileURL(__filename).toString()) : require; | ||
| var isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE || ''); | ||
| var satisfiesSemverSync = null; | ||
| function resolveVersion(version, options) { | ||
| if (!satisfiesSemverSync) satisfiesSemverSync = _require('node-exec-path').satisfiesSemverSync; | ||
| var opts = (options === null || options === void 0 ? void 0 : options.env) ? { | ||
| env: options.env | ||
| } : {}; | ||
| var execPath = satisfiesSemverSync(version, opts); | ||
| if (!execPath) throw new Error('node-version-call-local: No Node matching "'.concat(version, '" found in PATH')); | ||
| var installPath = isWindows ? _path.default.join(execPath, '..') : _path.default.join(execPath, '..', '..'); | ||
| return { | ||
| execPath: execPath, | ||
| installPath: installPath | ||
| }; | ||
| } | ||
| /* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; } |
| {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-call-local/src/lib/resolveVersion.ts"],"sourcesContent":["import Module from 'module';\nimport type { satisfiesSemverSyncOptions } from 'node-exec-path';\nimport path from 'path';\n\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE || '');\n\nlet satisfiesSemverSync: (version: string, options?: satisfiesSemverSyncOptions) => string | null = null;\n\nexport type ResolvedVersion = { execPath: string; installPath: string };\nexport type ResolveOptions = { env?: NodeJS.ProcessEnv };\n\nexport default function resolveVersion(version: string, options?: ResolveOptions): ResolvedVersion {\n if (!satisfiesSemverSync) satisfiesSemverSync = _require('node-exec-path').satisfiesSemverSync;\n const opts = options?.env ? { env: options.env } : {};\n const execPath = satisfiesSemverSync(version, opts);\n if (!execPath) throw new Error(`node-version-call-local: No Node matching \"${version}\" found in PATH`);\n const installPath = isWindows ? path.join(execPath, '..') : path.join(execPath, '..', '..');\n return { execPath, installPath };\n}\n"],"names":["resolveVersion","_require","require","Module","createRequire","isWindows","process","platform","test","env","OSTYPE","satisfiesSemverSync","version","options","opts","execPath","Error","installPath","path","join"],"mappings":";;;;+BAYA;;;eAAwBA;;;6DAZL;2DAEF;;;;;;AAEjB,IAAMC,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAC1F,IAAMG,YAAYC,QAAQC,QAAQ,KAAK,WAAW,kBAAkBC,IAAI,CAACF,QAAQG,GAAG,CAACC,MAAM,IAAI;AAE/F,IAAIC,sBAAgG;AAKrF,SAASX,eAAeY,OAAe,EAAEC,OAAwB;IAC9E,IAAI,CAACF,qBAAqBA,sBAAsBV,SAAS,kBAAkBU,mBAAmB;IAC9F,IAAMG,OAAOD,CAAAA,oBAAAA,8BAAAA,QAASJ,GAAG,IAAG;QAAEA,KAAKI,QAAQJ,GAAG;IAAC,IAAI,CAAC;IACpD,IAAMM,WAAWJ,oBAAoBC,SAASE;IAC9C,IAAI,CAACC,UAAU,MAAM,IAAIC,MAAM,AAAC,8CAAqD,OAARJ,SAAQ;IACrF,IAAMK,cAAcZ,YAAYa,aAAI,CAACC,IAAI,CAACJ,UAAU,QAAQG,aAAI,CAACC,IAAI,CAACJ,UAAU,MAAM;IACtF,OAAO;QAAEA,UAAAA;QAAUE,aAAAA;IAAY;AACjC"} |
| export type ResolvedVersion = { | ||
| execPath: string; | ||
| installPath: string; | ||
| }; | ||
| export type ResolveOptions = { | ||
| env?: NodeJS.ProcessEnv; | ||
| }; | ||
| export default function resolveVersion(version: string, options?: ResolveOptions): ResolvedVersion; |
| import Module from 'module'; | ||
| import path from 'path'; | ||
| const _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require; | ||
| const isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE || ''); | ||
| let satisfiesSemverSync = null; | ||
| export default function resolveVersion(version, options) { | ||
| if (!satisfiesSemverSync) satisfiesSemverSync = _require('node-exec-path').satisfiesSemverSync; | ||
| const opts = (options === null || options === void 0 ? void 0 : options.env) ? { | ||
| env: options.env | ||
| } : {}; | ||
| const execPath = satisfiesSemverSync(version, opts); | ||
| if (!execPath) throw new Error(`node-version-call-local: No Node matching "${version}" found in PATH`); | ||
| const installPath = isWindows ? path.join(execPath, '..') : path.join(execPath, '..', '..'); | ||
| return { | ||
| execPath, | ||
| installPath | ||
| }; | ||
| } |
| {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-call-local/src/lib/resolveVersion.ts"],"sourcesContent":["import Module from 'module';\nimport type { satisfiesSemverSyncOptions } from 'node-exec-path';\nimport path from 'path';\n\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE || '');\n\nlet satisfiesSemverSync: (version: string, options?: satisfiesSemverSyncOptions) => string | null = null;\n\nexport type ResolvedVersion = { execPath: string; installPath: string };\nexport type ResolveOptions = { env?: NodeJS.ProcessEnv };\n\nexport default function resolveVersion(version: string, options?: ResolveOptions): ResolvedVersion {\n if (!satisfiesSemverSync) satisfiesSemverSync = _require('node-exec-path').satisfiesSemverSync;\n const opts = options?.env ? { env: options.env } : {};\n const execPath = satisfiesSemverSync(version, opts);\n if (!execPath) throw new Error(`node-version-call-local: No Node matching \"${version}\" found in PATH`);\n const installPath = isWindows ? path.join(execPath, '..') : path.join(execPath, '..', '..');\n return { execPath, installPath };\n}\n"],"names":["Module","path","_require","require","createRequire","url","isWindows","process","platform","test","env","OSTYPE","satisfiesSemverSync","resolveVersion","version","options","opts","execPath","Error","installPath","join"],"mappings":"AAAA,OAAOA,YAAY,SAAS;AAE5B,OAAOC,UAAU,OAAO;AAExB,MAAMC,WAAW,OAAOC,YAAY,cAAcH,OAAOI,aAAa,CAAC,YAAYC,GAAG,IAAIF;AAC1F,MAAMG,YAAYC,QAAQC,QAAQ,KAAK,WAAW,kBAAkBC,IAAI,CAACF,QAAQG,GAAG,CAACC,MAAM,IAAI;AAE/F,IAAIC,sBAAgG;AAKpG,eAAe,SAASC,eAAeC,OAAe,EAAEC,OAAwB;IAC9E,IAAI,CAACH,qBAAqBA,sBAAsBV,SAAS,kBAAkBU,mBAAmB;IAC9F,MAAMI,OAAOD,CAAAA,oBAAAA,8BAAAA,QAASL,GAAG,IAAG;QAAEA,KAAKK,QAAQL,GAAG;IAAC,IAAI,CAAC;IACpD,MAAMO,WAAWL,oBAAoBE,SAASE;IAC9C,IAAI,CAACC,UAAU,MAAM,IAAIC,MAAM,CAAC,2CAA2C,EAAEJ,QAAQ,eAAe,CAAC;IACrG,MAAMK,cAAcb,YAAYL,KAAKmB,IAAI,CAACH,UAAU,QAAQhB,KAAKmB,IAAI,CAACH,UAAU,MAAM;IACtF,OAAO;QAAEA;QAAUE;IAAY;AACjC"} |
+15
-21
@@ -30,3 +30,3 @@ "use strict"; | ||
| var _semver = /*#__PURE__*/ _interop_require_default(require("semver")); | ||
| var _deriveInstallPathts = /*#__PURE__*/ _interop_require_default(require("./lib/deriveInstallPath.js")); | ||
| var _resolveVersionts = /*#__PURE__*/ _interop_require_default(require("./lib/resolveVersion.js")); | ||
| function _array_like_to_array(arr, len) { | ||
@@ -65,14 +65,2 @@ if (len == null || len > arr.length) len = arr.length; | ||
| var functionExec = null; | ||
| var satisfiesSemverSync = null; | ||
| function findExecPath(version, env) { | ||
| if (!satisfiesSemverSync) satisfiesSemverSync = _require('node-exec-path').satisfiesSemverSync; | ||
| var options = env ? { | ||
| env: env | ||
| } : {}; | ||
| var execPath = satisfiesSemverSync(version, options); | ||
| if (!execPath) { | ||
| throw new Error('node-version-call-local: No Node matching "'.concat(version, '" found in PATH')); | ||
| } | ||
| return execPath; | ||
| } | ||
| function call(version, workerPath, options) { | ||
@@ -108,5 +96,6 @@ for(var _len = arguments.length, args = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++){ | ||
| } | ||
| var execPath = findExecPath(version, opts.env); | ||
| var _resolveVersion = (0, _resolveVersionts.default)(version, { | ||
| env: opts.env | ||
| }), execPath = _resolveVersion.execPath, installPath = _resolveVersion.installPath; | ||
| if (useSpawnOptions) { | ||
| var installPath = (0, _deriveInstallPathts.default)(execPath); | ||
| var execOptions1 = (0, _nodeversionutils.spawnOptions)(installPath, { | ||
@@ -142,2 +131,3 @@ execPath: execPath, | ||
| var cachedExecPath = null; | ||
| var cachedInstallPath = null; | ||
| return function boundCaller() { | ||
@@ -152,3 +142,9 @@ for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){ | ||
| currentSatisfies = version === process.version || _semver.default.satisfies(process.version, version); | ||
| if (!currentSatisfies) cachedExecPath = findExecPath(version, opts.env); | ||
| if (!currentSatisfies) { | ||
| var resolved = (0, _resolveVersionts.default)(version, { | ||
| env: opts.env | ||
| }); | ||
| cachedExecPath = resolved.execPath; | ||
| cachedInstallPath = resolved.installPath; | ||
| } | ||
| initialized = true; | ||
@@ -177,7 +173,5 @@ } | ||
| } | ||
| var execPath = cachedExecPath; | ||
| if (useSpawnOptions) { | ||
| var installPath = (0, _deriveInstallPathts.default)(execPath); | ||
| var execOptions1 = (0, _nodeversionutils.spawnOptions)(installPath, { | ||
| execPath: execPath, | ||
| var execOptions1 = (0, _nodeversionutils.spawnOptions)(cachedInstallPath, { | ||
| execPath: cachedExecPath, | ||
| sleep: SLEEP_MS, | ||
@@ -193,3 +187,3 @@ callbacks: callbacks, | ||
| var execOptions2 = { | ||
| execPath: execPath, | ||
| execPath: cachedExecPath, | ||
| sleep: SLEEP_MS, | ||
@@ -196,0 +190,0 @@ callbacks: callbacks, |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-call-local/src/index.ts"],"sourcesContent":["import pathKey from 'env-path-key';\nimport type functionExecSync from 'function-exec-sync';\nimport Module from 'module';\nimport type { satisfiesSemverSyncOptions } from 'node-exec-path';\nimport { type SpawnOptions, spawnOptions } from 'node-version-utils';\nimport semver from 'semver';\nimport deriveInstallPath from './lib/deriveInstallPath.ts';\n\nimport type { BindOptions, BoundCaller, CallerCallback, CallOptions } from './types.ts';\n\nexport type * from './types.ts';\n\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst SLEEP_MS = 60;\n\nlet functionExec: typeof functionExecSync = null;\nlet satisfiesSemverSync: (version: string, options?: satisfiesSemverSyncOptions) => string | null = null;\n\nfunction findExecPath(version: string, env?: NodeJS.ProcessEnv): string {\n if (!satisfiesSemverSync) satisfiesSemverSync = _require('node-exec-path').satisfiesSemverSync;\n const options = env ? { env } : {};\n const execPath = satisfiesSemverSync(version, options);\n if (!execPath) {\n throw new Error(`node-version-call-local: No Node matching \"${version}\" found in PATH`);\n }\n return execPath;\n}\n\n/**\n * Call a function in a Node version found in PATH.\n *\n * @param version - Semver constraint ('>0.12', '>=18', '^16') or exact ('v18.0.0')\n * @param workerPath - Path to the file to execute\n * @param options - Execution options\n * @param args - Arguments to pass to the worker\n */\nexport default function call(version: string, workerPath: string, options?: CallOptions, ...args: unknown[]): unknown {\n const opts = options || {};\n const callbacks = opts.callbacks === true; // default false (matches function-exec-sync)\n const useSpawnOptions = opts.spawnOptions !== false; // default true\n const env = opts.env || process.env;\n\n const currentSatisfies = version === process.version || semver.satisfies(process.version, version);\n\n if (currentSatisfies && !callbacks) {\n const fn = _require(workerPath);\n return typeof fn === 'function' ? fn.apply(null, args) : fn;\n }\n\n if (!functionExec) functionExec = _require('function-exec-sync');\n\n if (currentSatisfies) {\n const PATH_KEY = pathKey();\n if (opts.env && !opts.env[PATH_KEY]) {\n throw new Error(`node-version-call-local: options.env missing required ${PATH_KEY}`);\n }\n const execOptions = { execPath: process.execPath, sleep: SLEEP_MS, callbacks: true, env };\n return functionExec.apply(null, [execOptions, workerPath, ...args]);\n }\n\n const execPath = findExecPath(version, opts.env);\n\n if (useSpawnOptions) {\n const installPath = deriveInstallPath(execPath);\n const execOptions = spawnOptions(installPath, { execPath, sleep: SLEEP_MS, callbacks, env } as SpawnOptions);\n return functionExec.apply(null, [execOptions, workerPath, ...args]);\n }\n\n const execOptions = { execPath, sleep: SLEEP_MS, callbacks, env };\n return functionExec.apply(null, [execOptions, workerPath, ...args]);\n}\n\n/**\n * Create a bound caller for a specific version and worker.\n * Looks up the execPath ONCE on first call (lazy) and caches it.\n *\n * @param version - Semver constraint ('>0.12', '>=18', '^16') or exact ('v18.0.0')\n * @param workerPath - Path to the file to execute\n * @param options - Execution options\n * @returns A function that calls the worker with the bound version/path/options\n */\nexport function bind(version: string, workerPath: string, options?: BindOptions): BoundCaller {\n const opts = options || {};\n const callbacks = opts.callbacks === true; // default false (matches function-exec-sync)\n const useSpawnOptions = opts.spawnOptions !== false; // default true\n const env = opts.env || process.env;\n\n let initialized = false;\n let currentSatisfies: boolean;\n let cachedExecPath: string | null = null;\n\n return function boundCaller(...args: unknown[]): unknown {\n const lastArg = args[args.length - 1];\n const hasCallback = typeof lastArg === 'function';\n\n const execute = (): unknown => {\n if (!initialized) {\n currentSatisfies = version === process.version || semver.satisfies(process.version, version);\n if (!currentSatisfies) cachedExecPath = findExecPath(version, opts.env);\n initialized = true;\n }\n\n if (currentSatisfies && !callbacks) {\n const fn = _require(workerPath);\n return typeof fn === 'function' ? fn.apply(null, args) : fn;\n }\n\n if (!functionExec) functionExec = _require('function-exec-sync');\n\n if (currentSatisfies) {\n const PATH_KEY = pathKey();\n if (opts.env && !opts.env[PATH_KEY]) {\n throw new Error(`node-version-call-local: options.env missing required ${PATH_KEY}`);\n }\n const execOptions = { execPath: process.execPath, sleep: SLEEP_MS, callbacks: true, env };\n return functionExec.apply(null, [execOptions, workerPath, ...args]);\n }\n\n const execPath = cachedExecPath;\n\n if (useSpawnOptions) {\n const installPath = deriveInstallPath(execPath);\n const execOptions = spawnOptions(installPath, { execPath, sleep: SLEEP_MS, callbacks, env } as SpawnOptions);\n return functionExec.apply(null, [execOptions, workerPath, ...args]);\n }\n\n const execOptions = { execPath, sleep: SLEEP_MS, callbacks, env };\n return functionExec.apply(null, [execOptions, workerPath, ...args]);\n };\n\n if (hasCallback) {\n const callback = args.pop() as CallerCallback;\n try {\n const result = execute();\n callback(null, result);\n return undefined;\n } catch (err) {\n callback(err);\n return undefined;\n }\n }\n\n return execute();\n };\n}\n"],"names":["bind","call","_require","require","Module","createRequire","SLEEP_MS","functionExec","satisfiesSemverSync","findExecPath","version","env","options","execPath","Error","workerPath","args","opts","callbacks","useSpawnOptions","spawnOptions","process","currentSatisfies","semver","satisfies","fn","apply","PATH_KEY","pathKey","execOptions","sleep","installPath","deriveInstallPath","initialized","cachedExecPath","boundCaller","lastArg","length","hasCallback","execute","callback","pop","result","undefined","err"],"mappings":";;;;;;;;;;;QAiFgBA;eAAAA;;QArDhB;;;;;;;CAOC,GACD;eAAwBC;;;iEApCJ;6DAED;gCAE6B;6DAC7B;0EACW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AWP,KAAAA;YAAI;YAChE,OAAOJ,aAAamB,KAAK,CAAC,MAAM;gBAACG;gBAAad;aAAoB,CAAlC,OAA0B,qBAAGC;QAC/D;QAEA,IAAIsB,aAAa;YACf,IAAME,WAAWxB,KAAKyB,GAAG;YACzB,IAAI;gBACF,IAAMC,SAASH;gBACfC,SAAS,MAAME;gBACf,OAAOC;YACT,EAAE,OAAOC,KAAK;gBACZJ,SAASI;gBACT,OAAOD;YACT;QACF;QAEA,OAAOJ;IACT;AACF"} | ||
| {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-call-local/src/index.ts"],"sourcesContent":["import pathKey from 'env-path-key';\nimport type functionExecSync from 'function-exec-sync';\nimport Module from 'module';\nimport { type SpawnOptions, spawnOptions } from 'node-version-utils';\nimport semver from 'semver';\n\nimport resolveVersion from './lib/resolveVersion.ts';\nimport type { BindOptions, BoundCaller, CallerCallback, CallOptions } from './types.ts';\n\nexport type * from './types.ts';\n\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst SLEEP_MS = 60;\n\nlet functionExec: typeof functionExecSync = null;\n\n/**\n * Call a function in a Node version found in PATH.\n *\n * @param version - Semver constraint ('>0.12', '>=18', '^16') or exact ('v18.0.0')\n * @param workerPath - Path to the file to execute\n * @param options - Execution options\n * @param args - Arguments to pass to the worker\n */\nexport default function call(version: string, workerPath: string, options?: CallOptions, ...args: unknown[]): unknown {\n const opts = options || {};\n const callbacks = opts.callbacks === true; // default false (matches function-exec-sync)\n const useSpawnOptions = opts.spawnOptions !== false; // default true\n const env = opts.env || process.env;\n\n const currentSatisfies = version === process.version || semver.satisfies(process.version, version);\n\n if (currentSatisfies && !callbacks) {\n const fn = _require(workerPath);\n return typeof fn === 'function' ? fn.apply(null, args) : fn;\n }\n\n if (!functionExec) functionExec = _require('function-exec-sync');\n\n if (currentSatisfies) {\n const PATH_KEY = pathKey();\n if (opts.env && !opts.env[PATH_KEY]) {\n throw new Error(`node-version-call-local: options.env missing required ${PATH_KEY}`);\n }\n const execOptions = { execPath: process.execPath, sleep: SLEEP_MS, callbacks: true, env };\n return functionExec.apply(null, [execOptions, workerPath, ...args]);\n }\n\n const { execPath, installPath } = resolveVersion(version, { env: opts.env });\n\n if (useSpawnOptions) {\n const execOptions = spawnOptions(installPath, { execPath, sleep: SLEEP_MS, callbacks, env } as SpawnOptions);\n return functionExec.apply(null, [execOptions, workerPath, ...args]);\n }\n\n const execOptions = { execPath, sleep: SLEEP_MS, callbacks, env };\n return functionExec.apply(null, [execOptions, workerPath, ...args]);\n}\n\n/**\n * Create a bound caller for a specific version and worker.\n * Looks up the execPath ONCE on first call (lazy) and caches it.\n *\n * @param version - Semver constraint ('>0.12', '>=18', '^16') or exact ('v18.0.0')\n * @param workerPath - Path to the file to execute\n * @param options - Execution options\n * @returns A function that calls the worker with the bound version/path/options\n */\nexport function bind(version: string, workerPath: string, options?: BindOptions): BoundCaller {\n const opts = options || {};\n const callbacks = opts.callbacks === true; // default false (matches function-exec-sync)\n const useSpawnOptions = opts.spawnOptions !== false; // default true\n const env = opts.env || process.env;\n\n let initialized = false;\n let currentSatisfies: boolean;\n let cachedExecPath: string | null = null;\n let cachedInstallPath: string | null = null;\n\n return function boundCaller(...args: unknown[]): unknown {\n const lastArg = args[args.length - 1];\n const hasCallback = typeof lastArg === 'function';\n\n const execute = (): unknown => {\n if (!initialized) {\n currentSatisfies = version === process.version || semver.satisfies(process.version, version);\n if (!currentSatisfies) {\n const resolved = resolveVersion(version, { env: opts.env });\n cachedExecPath = resolved.execPath;\n cachedInstallPath = resolved.installPath;\n }\n initialized = true;\n }\n\n if (currentSatisfies && !callbacks) {\n const fn = _require(workerPath);\n return typeof fn === 'function' ? fn.apply(null, args) : fn;\n }\n\n if (!functionExec) functionExec = _require('function-exec-sync');\n\n if (currentSatisfies) {\n const PATH_KEY = pathKey();\n if (opts.env && !opts.env[PATH_KEY]) {\n throw new Error(`node-version-call-local: options.env missing required ${PATH_KEY}`);\n }\n const execOptions = { execPath: process.execPath, sleep: SLEEP_MS, callbacks: true, env };\n return functionExec.apply(null, [execOptions, workerPath, ...args]);\n }\n\n if (useSpawnOptions) {\n const execOptions = spawnOptions(cachedInstallPath, { execPath: cachedExecPath, sleep: SLEEP_MS, callbacks, env } as SpawnOptions);\n return functionExec.apply(null, [execOptions, workerPath, ...args]);\n }\n\n const execOptions = { execPath: cachedExecPath, sleep: SLEEP_MS, callbacks, env };\n return functionExec.apply(null, [execOptions, workerPath, ...args]);\n };\n\n if (hasCallback) {\n const callback = args.pop() as CallerCallback;\n try {\n const result = execute();\n callback(null, result);\n return undefined;\n } catch (err) {\n callback(err);\n return undefined;\n }\n }\n\n return execute();\n };\n}\n"],"names":["bind","call","_require","require","Module","createRequire","SLEEP_MS","functionExec","version","workerPath","options","args","opts","callbacks","useSpawnOptions","spawnOptions","env","process","currentSatisfies","semver","satisfies","fn","apply","PATH_KEY","pathKey","Error","execOptions","execPath","sleep","resolveVersion","installPath","initialized","cachedExecPath","cachedInstallPath","boundCaller","lastArg","length","hasCallback","execute","resolved","callback","pop","result","undefined","err"],"mappings":";;;;;;;;;;;QAoEgBA;eAAAA;;QApDhB;;;;;;;CAOC,GACD;eAAwBC;;;iEAxBJ;6DAED;gCAC6B;6DAC7B;uEAEQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAK3B,IAAMC,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAC1F,IAAMG,WAAW;AAEjB,IAAIC,eAAwC;AAU7B,SAASN,KAAKO,OAAe,EAAEC,UAAkB,EAAEC,OAAqB;IAAE,IAAA,IAAA,OAAA,UAAA,QAAA,AAAGC,OAAH,UAAA,OAAA,IAAA,OAAA,QAAA,OAAA,GAAA,OAAA,MAAA;QAAGA,KAAH,OAAA,KAAA,SAAA,CAAA,KAAkB;;IACzG,IAAMC,OAAOF,WAAW,CAAC;IACzB,IAAMG,YAAYD,KAAKC,SAAS,KAAK,MAAM,6CAA6C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AI,CAACJ,KAAKI,GAAG,CAACO,SAAS,EAAE;oBACnC,MAAM,IAAIE,MAAM,AAAC,yDAAiE,OAATF;gBAC3E;gBACA,IAAMG,cAAc;oBAAEC,UAAUV,QAAQU,QAAQ;oBAAEC,OAAOtB;oBAAUO,WAAW;oBAAMG,KAAAA;gBAAI;gBACxF,OAAOT,aAAae,KAAK,CAAC,MAAM;oBAACI;oBAAajB;iBAAoB,CAAlC,OAA0B,qBAAGE;YAC/D;YAEA,IAAIG,iBAAiB;gBACnB,IAAMY,eAAcX,IAAAA,8BAAY,EAACkB,mBAAmB;oBAAEN,UAAUK;oBAAgBJ,OAAOtB;oBAAUO,WAAAA;oBAAWG,KAAAA;gBAAI;gBAChH,OAAOT,aAAae,KAAK,CAAC,MAAM;oBAACI;oBAAajB;iBAAoB,CAAlC,OAA0B,qBAAGE;YAC/D;YAEA,IAAMe,eAAc;gBAAEC,UAAUK;gBAAgBJ,OAAOtB;gBAAUO,WAAAA;gBAAWG,KAAAA;YAAI;YAChF,OAAOT,aAAae,KAAK,CAAC,MAAM;gBAACI;gBAAajB;aAAoB,CAAlC,OAA0B,qBAAGE;QAC/D;QAEA,IAAI0B,aAAa;YACf,IAAMG,WAAW7B,KAAK8B,GAAG;YACzB,IAAI;gBACF,IAAMC,SAASJ;gBACfE,SAAS,MAAME;gBACf,OAAOC;YACT,EAAE,OAAOC,KAAK;gBACZJ,SAASI;gBACT,OAAOD;YACT;QACF;QAEA,OAAOL;IACT;AACF"} |
+15
-21
@@ -5,18 +5,6 @@ import pathKey from 'env-path-key'; | ||
| import semver from 'semver'; | ||
| import deriveInstallPath from './lib/deriveInstallPath.js'; | ||
| import resolveVersion from './lib/resolveVersion.js'; | ||
| const _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require; | ||
| const SLEEP_MS = 60; | ||
| let functionExec = null; | ||
| let satisfiesSemverSync = null; | ||
| function findExecPath(version, env) { | ||
| if (!satisfiesSemverSync) satisfiesSemverSync = _require('node-exec-path').satisfiesSemverSync; | ||
| const options = env ? { | ||
| env | ||
| } : {}; | ||
| const execPath = satisfiesSemverSync(version, options); | ||
| if (!execPath) { | ||
| throw new Error(`node-version-call-local: No Node matching "${version}" found in PATH`); | ||
| } | ||
| return execPath; | ||
| } | ||
| /** | ||
@@ -57,5 +45,6 @@ * Call a function in a Node version found in PATH. | ||
| } | ||
| const execPath = findExecPath(version, opts.env); | ||
| const { execPath, installPath } = resolveVersion(version, { | ||
| env: opts.env | ||
| }); | ||
| if (useSpawnOptions) { | ||
| const installPath = deriveInstallPath(execPath); | ||
| const execOptions = spawnOptions(installPath, { | ||
@@ -101,2 +90,3 @@ execPath, | ||
| let cachedExecPath = null; | ||
| let cachedInstallPath = null; | ||
| return function boundCaller(...args) { | ||
@@ -108,3 +98,9 @@ const lastArg = args[args.length - 1]; | ||
| currentSatisfies = version === process.version || semver.satisfies(process.version, version); | ||
| if (!currentSatisfies) cachedExecPath = findExecPath(version, opts.env); | ||
| if (!currentSatisfies) { | ||
| const resolved = resolveVersion(version, { | ||
| env: opts.env | ||
| }); | ||
| cachedExecPath = resolved.execPath; | ||
| cachedInstallPath = resolved.installPath; | ||
| } | ||
| initialized = true; | ||
@@ -134,7 +130,5 @@ } | ||
| } | ||
| const execPath = cachedExecPath; | ||
| if (useSpawnOptions) { | ||
| const installPath = deriveInstallPath(execPath); | ||
| const execOptions = spawnOptions(installPath, { | ||
| execPath, | ||
| const execOptions = spawnOptions(cachedInstallPath, { | ||
| execPath: cachedExecPath, | ||
| sleep: SLEEP_MS, | ||
@@ -151,3 +145,3 @@ callbacks, | ||
| const execOptions = { | ||
| execPath, | ||
| execPath: cachedExecPath, | ||
| sleep: SLEEP_MS, | ||
@@ -154,0 +148,0 @@ callbacks, |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-call-local/src/index.ts"],"sourcesContent":["import pathKey from 'env-path-key';\nimport type functionExecSync from 'function-exec-sync';\nimport Module from 'module';\nimport type { satisfiesSemverSyncOptions } from 'node-exec-path';\nimport { type SpawnOptions, spawnOptions } from 'node-version-utils';\nimport semver from 'semver';\nimport deriveInstallPath from './lib/deriveInstallPath.ts';\n\nimport type { BindOptions, BoundCaller, CallerCallback, CallOptions } from './types.ts';\n\nexport type * from './types.ts';\n\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst SLEEP_MS = 60;\n\nlet functionExec: typeof functionExecSync = null;\nlet satisfiesSemverSync: (version: string, options?: satisfiesSemverSyncOptions) => string | null = null;\n\nfunction findExecPath(version: string, env?: NodeJS.ProcessEnv): string {\n if (!satisfiesSemverSync) satisfiesSemverSync = _require('node-exec-path').satisfiesSemverSync;\n const options = env ? { env } : {};\n const execPath = satisfiesSemverSync(version, options);\n if (!execPath) {\n throw new Error(`node-version-call-local: No Node matching \"${version}\" found in PATH`);\n }\n return execPath;\n}\n\n/**\n * Call a function in a Node version found in PATH.\n *\n * @param version - Semver constraint ('>0.12', '>=18', '^16') or exact ('v18.0.0')\n * @param workerPath - Path to the file to execute\n * @param options - Execution options\n * @param args - Arguments to pass to the worker\n */\nexport default function call(version: string, workerPath: string, options?: CallOptions, ...args: unknown[]): unknown {\n const opts = options || {};\n const callbacks = opts.callbacks === true; // default false (matches function-exec-sync)\n const useSpawnOptions = opts.spawnOptions !== false; // default true\n const env = opts.env || process.env;\n\n const currentSatisfies = version === process.version || semver.satisfies(process.version, version);\n\n if (currentSatisfies && !callbacks) {\n const fn = _require(workerPath);\n return typeof fn === 'function' ? fn.apply(null, args) : fn;\n }\n\n if (!functionExec) functionExec = _require('function-exec-sync');\n\n if (currentSatisfies) {\n const PATH_KEY = pathKey();\n if (opts.env && !opts.env[PATH_KEY]) {\n throw new Error(`node-version-call-local: options.env missing required ${PATH_KEY}`);\n }\n const execOptions = { execPath: process.execPath, sleep: SLEEP_MS, callbacks: true, env };\n return functionExec.apply(null, [execOptions, workerPath, ...args]);\n }\n\n const execPath = findExecPath(version, opts.env);\n\n if (useSpawnOptions) {\n const installPath = deriveInstallPath(execPath);\n const execOptions = spawnOptions(installPath, { execPath, sleep: SLEEP_MS, callbacks, env } as SpawnOptions);\n return functionExec.apply(null, [execOptions, workerPath, ...args]);\n }\n\n const execOptions = { execPath, sleep: SLEEP_MS, callbacks, env };\n return functionExec.apply(null, [execOptions, workerPath, ...args]);\n}\n\n/**\n * Create a bound caller for a specific version and worker.\n * Looks up the execPath ONCE on first call (lazy) and caches it.\n *\n * @param version - Semver constraint ('>0.12', '>=18', '^16') or exact ('v18.0.0')\n * @param workerPath - Path to the file to execute\n * @param options - Execution options\n * @returns A function that calls the worker with the bound version/path/options\n */\nexport function bind(version: string, workerPath: string, options?: BindOptions): BoundCaller {\n const opts = options || {};\n const callbacks = opts.callbacks === true; // default false (matches function-exec-sync)\n const useSpawnOptions = opts.spawnOptions !== false; // default true\n const env = opts.env || process.env;\n\n let initialized = false;\n let currentSatisfies: boolean;\n let cachedExecPath: string | null = null;\n\n return function boundCaller(...args: unknown[]): unknown {\n const lastArg = args[args.length - 1];\n const hasCallback = typeof lastArg === 'function';\n\n const execute = (): unknown => {\n if (!initialized) {\n currentSatisfies = version === process.version || semver.satisfies(process.version, version);\n if (!currentSatisfies) cachedExecPath = findExecPath(version, opts.env);\n initialized = true;\n }\n\n if (currentSatisfies && !callbacks) {\n const fn = _require(workerPath);\n return typeof fn === 'function' ? fn.apply(null, args) : fn;\n }\n\n if (!functionExec) functionExec = _require('function-exec-sync');\n\n if (currentSatisfies) {\n const PATH_KEY = pathKey();\n if (opts.env && !opts.env[PATH_KEY]) {\n throw new Error(`node-version-call-local: options.env missing required ${PATH_KEY}`);\n }\n const execOptions = { execPath: process.execPath, sleep: SLEEP_MS, callbacks: true, env };\n return functionExec.apply(null, [execOptions, workerPath, ...args]);\n }\n\n const execPath = cachedExecPath;\n\n if (useSpawnOptions) {\n const installPath = deriveInstallPath(execPath);\n const execOptions = spawnOptions(installPath, { execPath, sleep: SLEEP_MS, callbacks, env } as SpawnOptions);\n return functionExec.apply(null, [execOptions, workerPath, ...args]);\n }\n\n const execOptions = { execPath, sleep: SLEEP_MS, callbacks, env };\n return functionExec.apply(null, [execOptions, workerPath, ...args]);\n };\n\n if (hasCallback) {\n const callback = args.pop() as CallerCallback;\n try {\n const result = execute();\n callback(null, result);\n return undefined;\n } catch (err) {\n callback(err);\n return undefined;\n }\n }\n\n return execute();\n };\n}\n"],"names":["pathKey","Module","spawnOptions","semver","deriveInstallPath","_require","require","createRequire","url","SLEEP_MS","functionExec","satisfiesSemverSync","findExecPath","version","env","options","execPath","Error","call","workerPath","args","opts","callbacks","useSpawnOptions","process","currentSatisfies","satisfies","fn","apply","PATH_KEY","execOptions","sleep","installPath","bind","initialized","cachedExecPath","boundCaller","lastArg","length","hasCallback","execute","callback","pop","result","undefined","err"],"mappings":"AAAA,OAAOA,aAAa,eAAe;AAEnC,OAAOC,YAAY,SAAS;AAE5B,SAA4BC,YAAY,QAAQ,qBAAqB;AACrE,OAAOC,YAAY,SAAS;AAC5B,OAAOC,uBAAuB,6BAA6B;AAM3D,MAAMC,WAAW,OAAOC,YAAY,cAAcL,OAAOM,aAAa,CAAC,YAAYC,GAAG,IAAIF;AAC1F,MAAMG,WAAW;AAEjB,IAAIC,eAAwC;AAC5C,IAAIC,sBAAgG;AAEpG,SAASC,aAAaC,OAAe,EAAEC,GAAuB;IAC5D,IAAI,CAACH,qBAAqBA,sBAAsBN,SAAS,kBAAkBM,mBAAmB;IAC9F,MAAMI,UAAUD,MAAM;QAAEA;IAAI,IAAI,CAAC;IACjC,MAAME,WAAWL,oBAAoBE,SAASE;IAC9C,IAAI,CAACC,UAAU;QACb,MAAM,IAAIC,MAAM,CAAC,2CAA2C,EAAEJ,QAAQ,eAAe,CAAC;IACxF;IACA,OAAOG;AACT;AAEA;;;;;;;CAOC,GACD,eAAe,SAASE,KAAKL,OAAe,EAAEM,UAAkB,EAAEJ,OAAqB,EAAE,GAAGK,IAAe;IACzG,MAAMC,OAAON,WAA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Ac5B,kBAAkBY;gBACtC,MAAMc,cAAc5B,aAAa8B,aAAa;oBAAEhB;oBAAUe,OAAOtB;oBAAUa;oBAAWR;gBAAI;gBAC1F,OAAOJ,aAAakB,KAAK,CAAC,MAAM;oBAACE;oBAAaX;uBAAeC;iBAAK;YACpE;YAEA,MAAMU,cAAc;gBAAEd;gBAAUe,OAAOtB;gBAAUa;gBAAWR;YAAI;YAChE,OAAOJ,aAAakB,KAAK,CAAC,MAAM;gBAACE;gBAAaX;mBAAeC;aAAK;QACpE;QAEA,IAAImB,aAAa;YACf,MAAME,WAAWrB,KAAKsB,GAAG;YACzB,IAAI;gBACF,MAAMC,SAASH;gBACfC,SAAS,MAAME;gBACf,OAAOC;YACT,EAAE,OAAOC,KAAK;gBACZJ,SAASI;gBACT,OAAOD;YACT;QACF;QAEA,OAAOJ;IACT;AACF"} | ||
| {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-call-local/src/index.ts"],"sourcesContent":["import pathKey from 'env-path-key';\nimport type functionExecSync from 'function-exec-sync';\nimport Module from 'module';\nimport { type SpawnOptions, spawnOptions } from 'node-version-utils';\nimport semver from 'semver';\n\nimport resolveVersion from './lib/resolveVersion.ts';\nimport type { BindOptions, BoundCaller, CallerCallback, CallOptions } from './types.ts';\n\nexport type * from './types.ts';\n\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst SLEEP_MS = 60;\n\nlet functionExec: typeof functionExecSync = null;\n\n/**\n * Call a function in a Node version found in PATH.\n *\n * @param version - Semver constraint ('>0.12', '>=18', '^16') or exact ('v18.0.0')\n * @param workerPath - Path to the file to execute\n * @param options - Execution options\n * @param args - Arguments to pass to the worker\n */\nexport default function call(version: string, workerPath: string, options?: CallOptions, ...args: unknown[]): unknown {\n const opts = options || {};\n const callbacks = opts.callbacks === true; // default false (matches function-exec-sync)\n const useSpawnOptions = opts.spawnOptions !== false; // default true\n const env = opts.env || process.env;\n\n const currentSatisfies = version === process.version || semver.satisfies(process.version, version);\n\n if (currentSatisfies && !callbacks) {\n const fn = _require(workerPath);\n return typeof fn === 'function' ? fn.apply(null, args) : fn;\n }\n\n if (!functionExec) functionExec = _require('function-exec-sync');\n\n if (currentSatisfies) {\n const PATH_KEY = pathKey();\n if (opts.env && !opts.env[PATH_KEY]) {\n throw new Error(`node-version-call-local: options.env missing required ${PATH_KEY}`);\n }\n const execOptions = { execPath: process.execPath, sleep: SLEEP_MS, callbacks: true, env };\n return functionExec.apply(null, [execOptions, workerPath, ...args]);\n }\n\n const { execPath, installPath } = resolveVersion(version, { env: opts.env });\n\n if (useSpawnOptions) {\n const execOptions = spawnOptions(installPath, { execPath, sleep: SLEEP_MS, callbacks, env } as SpawnOptions);\n return functionExec.apply(null, [execOptions, workerPath, ...args]);\n }\n\n const execOptions = { execPath, sleep: SLEEP_MS, callbacks, env };\n return functionExec.apply(null, [execOptions, workerPath, ...args]);\n}\n\n/**\n * Create a bound caller for a specific version and worker.\n * Looks up the execPath ONCE on first call (lazy) and caches it.\n *\n * @param version - Semver constraint ('>0.12', '>=18', '^16') or exact ('v18.0.0')\n * @param workerPath - Path to the file to execute\n * @param options - Execution options\n * @returns A function that calls the worker with the bound version/path/options\n */\nexport function bind(version: string, workerPath: string, options?: BindOptions): BoundCaller {\n const opts = options || {};\n const callbacks = opts.callbacks === true; // default false (matches function-exec-sync)\n const useSpawnOptions = opts.spawnOptions !== false; // default true\n const env = opts.env || process.env;\n\n let initialized = false;\n let currentSatisfies: boolean;\n let cachedExecPath: string | null = null;\n let cachedInstallPath: string | null = null;\n\n return function boundCaller(...args: unknown[]): unknown {\n const lastArg = args[args.length - 1];\n const hasCallback = typeof lastArg === 'function';\n\n const execute = (): unknown => {\n if (!initialized) {\n currentSatisfies = version === process.version || semver.satisfies(process.version, version);\n if (!currentSatisfies) {\n const resolved = resolveVersion(version, { env: opts.env });\n cachedExecPath = resolved.execPath;\n cachedInstallPath = resolved.installPath;\n }\n initialized = true;\n }\n\n if (currentSatisfies && !callbacks) {\n const fn = _require(workerPath);\n return typeof fn === 'function' ? fn.apply(null, args) : fn;\n }\n\n if (!functionExec) functionExec = _require('function-exec-sync');\n\n if (currentSatisfies) {\n const PATH_KEY = pathKey();\n if (opts.env && !opts.env[PATH_KEY]) {\n throw new Error(`node-version-call-local: options.env missing required ${PATH_KEY}`);\n }\n const execOptions = { execPath: process.execPath, sleep: SLEEP_MS, callbacks: true, env };\n return functionExec.apply(null, [execOptions, workerPath, ...args]);\n }\n\n if (useSpawnOptions) {\n const execOptions = spawnOptions(cachedInstallPath, { execPath: cachedExecPath, sleep: SLEEP_MS, callbacks, env } as SpawnOptions);\n return functionExec.apply(null, [execOptions, workerPath, ...args]);\n }\n\n const execOptions = { execPath: cachedExecPath, sleep: SLEEP_MS, callbacks, env };\n return functionExec.apply(null, [execOptions, workerPath, ...args]);\n };\n\n if (hasCallback) {\n const callback = args.pop() as CallerCallback;\n try {\n const result = execute();\n callback(null, result);\n return undefined;\n } catch (err) {\n callback(err);\n return undefined;\n }\n }\n\n return execute();\n };\n}\n"],"names":["pathKey","Module","spawnOptions","semver","resolveVersion","_require","require","createRequire","url","SLEEP_MS","functionExec","call","version","workerPath","options","args","opts","callbacks","useSpawnOptions","env","process","currentSatisfies","satisfies","fn","apply","PATH_KEY","Error","execOptions","execPath","sleep","installPath","bind","initialized","cachedExecPath","cachedInstallPath","boundCaller","lastArg","length","hasCallback","execute","resolved","callback","pop","result","undefined","err"],"mappings":"AAAA,OAAOA,aAAa,eAAe;AAEnC,OAAOC,YAAY,SAAS;AAC5B,SAA4BC,YAAY,QAAQ,qBAAqB;AACrE,OAAOC,YAAY,SAAS;AAE5B,OAAOC,oBAAoB,0BAA0B;AAKrD,MAAMC,WAAW,OAAOC,YAAY,cAAcL,OAAOM,aAAa,CAAC,YAAYC,GAAG,IAAIF;AAC1F,MAAMG,WAAW;AAEjB,IAAIC,eAAwC;AAE5C;;;;;;;CAOC,GACD,eAAe,SAASC,KAAKC,OAAe,EAAEC,UAAkB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AEC,OAAOpB;oBAAUQ,WAAW;oBAAME;gBAAI;gBACxF,OAAOT,aAAac,KAAK,CAAC,MAAM;oBAACG;oBAAad;uBAAeE;iBAAK;YACpE;YAEA,IAAIG,iBAAiB;gBACnB,MAAMS,cAAczB,aAAagC,mBAAmB;oBAAEN,UAAUK;oBAAgBJ,OAAOpB;oBAAUQ;oBAAWE;gBAAI;gBAChH,OAAOT,aAAac,KAAK,CAAC,MAAM;oBAACG;oBAAad;uBAAeE;iBAAK;YACpE;YAEA,MAAMY,cAAc;gBAAEC,UAAUK;gBAAgBJ,OAAOpB;gBAAUQ;gBAAWE;YAAI;YAChF,OAAOT,aAAac,KAAK,CAAC,MAAM;gBAACG;gBAAad;mBAAeE;aAAK;QACpE;QAEA,IAAIuB,aAAa;YACf,MAAMG,WAAW1B,KAAK2B,GAAG;YACzB,IAAI;gBACF,MAAMC,SAASJ;gBACfE,SAAS,MAAME;gBACf,OAAOC;YACT,EAAE,OAAOC,KAAK;gBACZJ,SAASI;gBACT,OAAOD;YACT;QACF;QAEA,OAAOL;IACT;AACF"} |
+1
-1
| { | ||
| "name": "node-version-call-local", | ||
| "version": "0.3.1", | ||
| "version": "0.3.2", | ||
| "description": "Call a function in a Node version found in PATH", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
| /** | ||
| * Derive the Node installation path from the execPath. | ||
| * Windows: node.exe is in the install root | ||
| * Unix: node is in <install>/bin/ | ||
| */ | ||
| export default function deriveInstallPath(execPath: string): string; |
| /** | ||
| * Derive the Node installation path from the execPath. | ||
| * Windows: node.exe is in the install root | ||
| * Unix: node is in <install>/bin/ | ||
| */ | ||
| export default function deriveInstallPath(execPath: string): string; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| Object.defineProperty(exports, /** | ||
| * Derive the Node installation path from the execPath. | ||
| * Windows: node.exe is in the install root | ||
| * Unix: node is in <install>/bin/ | ||
| */ "default", { | ||
| enumerable: true, | ||
| get: function() { | ||
| return deriveInstallPath; | ||
| } | ||
| }); | ||
| var _path = /*#__PURE__*/ _interop_require_default(require("path")); | ||
| function _interop_require_default(obj) { | ||
| return obj && obj.__esModule ? obj : { | ||
| default: obj | ||
| }; | ||
| } | ||
| var isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE || ''); | ||
| function deriveInstallPath(execPath) { | ||
| return isWindows ? _path.default.join(execPath, '..') : _path.default.join(execPath, '..', '..'); | ||
| } | ||
| /* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; } |
| {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-call-local/src/lib/deriveInstallPath.ts"],"sourcesContent":["import path from 'path';\n\nconst isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE || '');\n\n/**\n * Derive the Node installation path from the execPath.\n * Windows: node.exe is in the install root\n * Unix: node is in <install>/bin/\n */\nexport default function deriveInstallPath(execPath: string): string {\n return isWindows ? path.join(execPath, '..') : path.join(execPath, '..', '..');\n}\n"],"names":["deriveInstallPath","isWindows","process","platform","test","env","OSTYPE","execPath","path","join"],"mappings":";;;;+BAIA;;;;CAIC,GACD;;;eAAwBA;;;2DATP;;;;;;AAEjB,IAAMC,YAAYC,QAAQC,QAAQ,KAAK,WAAW,kBAAkBC,IAAI,CAACF,QAAQG,GAAG,CAACC,MAAM,IAAI;AAOhF,SAASN,kBAAkBO,QAAgB;IACxD,OAAON,YAAYO,aAAI,CAACC,IAAI,CAACF,UAAU,QAAQC,aAAI,CAACC,IAAI,CAACF,UAAU,MAAM;AAC3E"} |
| /** | ||
| * Derive the Node installation path from the execPath. | ||
| * Windows: node.exe is in the install root | ||
| * Unix: node is in <install>/bin/ | ||
| */ | ||
| export default function deriveInstallPath(execPath: string): string; |
| import path from 'path'; | ||
| const isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE || ''); | ||
| /** | ||
| * Derive the Node installation path from the execPath. | ||
| * Windows: node.exe is in the install root | ||
| * Unix: node is in <install>/bin/ | ||
| */ export default function deriveInstallPath(execPath) { | ||
| return isWindows ? path.join(execPath, '..') : path.join(execPath, '..', '..'); | ||
| } |
| {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-call-local/src/lib/deriveInstallPath.ts"],"sourcesContent":["import path from 'path';\n\nconst isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE || '');\n\n/**\n * Derive the Node installation path from the execPath.\n * Windows: node.exe is in the install root\n * Unix: node is in <install>/bin/\n */\nexport default function deriveInstallPath(execPath: string): string {\n return isWindows ? path.join(execPath, '..') : path.join(execPath, '..', '..');\n}\n"],"names":["path","isWindows","process","platform","test","env","OSTYPE","deriveInstallPath","execPath","join"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AAExB,MAAMC,YAAYC,QAAQC,QAAQ,KAAK,WAAW,kBAAkBC,IAAI,CAACF,QAAQG,GAAG,CAACC,MAAM,IAAI;AAE/F;;;;CAIC,GACD,eAAe,SAASC,kBAAkBC,QAAgB;IACxD,OAAOP,YAAYD,KAAKS,IAAI,CAACD,UAAU,QAAQR,KAAKS,IAAI,CAACD,UAAU,MAAM;AAC3E"} |
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
51188
3.27%498
2.05%10
25%