Skip to content

relizy / withRegistryNpmrc

Function: withRegistryNpmrc() ​

withRegistryNpmrc<T>(__namedParameters): Promise<T>

Defined in: src/core/npm.ts:368

Run fn with the registry target's auth token and scope registry temporarily written to the project .npmrc (at config.cwd), then restore the original file - or remove it if it did not exist - ALWAYS, even on failure.

This is the version-proof replacement for passing rc-options as CLI flags: the .npmrc contract is stable across npm/pnpm/bun and every version, so we never depend on the CLI argument parser (which pnpm changed in v10+). Only the keys relizy manages are overridden; every other line already in the user's .npmrc is preserved untouched. When there is nothing to inject (no token/scope, or a package manager that does not read .npmrc such as yarn), the .npmrc is left as-is and fn runs against the user's own config.

Type Parameters ​

T ​

T

Parameters ​

__namedParameters ​

config ​

ResolvedRelizyConfig

fn ​

() => Promise<T>

packageManager ​

PackageManager

packageName? ​

string

registryTarget ​

RegistryTarget

Returns ​

Promise<T>

Released under the MIT License.