From b9c5c5c29036ee1f18de5f60096e47717d764971 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Wed, 6 Nov 2024 17:32:32 +0100 Subject: [PATCH] feat: setting a custom uplink registry --- package.json | 2 +- src/index.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index e1756d4..348a1a3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@pnpm/registry-mock", - "version": "3.43.0", + "version": "3.44.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 1b89951..8e7c17f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -56,7 +56,11 @@ export const getIntegrity = (pkgName: string, pkgVersion: string): string => { export { REGISTRY_MOCK_PORT } -export function prepare () { +export interface PrepareOptions { + uplinkedRegistry?: string +} + +export function prepare (opts?: PrepareOptions) { const tempy = require('tempy') const storage = tempy.directory() @@ -68,7 +72,7 @@ export function prepare () { storage, uplinks: { npmjs: { - url: process.env['PNPM_REGISTRY_MOCK_UPLINK'] || 'https://registry.npmjs.org/', + url: opts?.uplinkedRegistry || process.env['PNPM_REGISTRY_MOCK_UPLINK'] || 'https://registry.npmjs.org/', // performance improvements // https://verdaccio.org/docs/en/uplinks