From 6d34d84557f502ebaebc98618d61741a56cf7c08 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Thu, 25 Jul 2024 03:12:14 +0200 Subject: [PATCH] feat: allow to start verdaccio with custom node.js version --- package.json | 2 +- src/index.ts | 28 +++++++++++++++++----------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index ac883ca..65819c5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@pnpm/registry-mock", - "version": "3.37.0", + "version": "3.38.0", "description": "Mock the npm registry", "main": "dist/index.js", "bin": "dist/bin/pnpm-registry-mock.js", diff --git a/src/index.ts b/src/index.ts index 627217b..1b89951 100644 --- a/src/index.ts +++ b/src/index.ts @@ -24,18 +24,24 @@ export default function () { ) } -export function start (opts: execa.Options) { +export function start (opts: execa.Options & { useNodeVersion?: string }) { const verdaccioBin = require.resolve('verdaccio/bin/verdaccio') - return execa('node', - [ - verdaccioBin, - '--config', - locations.configPath(), - '--listen', - REGISTRY_MOCK_PORT - ], - opts - ) + const args = [ + verdaccioBin, + '--config', + locations.configPath(), + '--listen', + REGISTRY_MOCK_PORT + ] + if (opts.useNodeVersion) { + return execa('pnpm', [ + `--use-node-version=${opts.useNodeVersion}`, + 'exec', + 'node', + ...args, + ], opts) + } + return execa('node', args, opts) } export const addDistTag = _addDistTag(REGISTRY_MOCK_PORT)