MCPcopy Index your code
hub / github.com/changesets/changesets / getCorrectRegistry

Function getCorrectRegistry

packages/cli/src/commands/publish/npm-utils.ts:58–82  ·  view source on GitHub ↗
(packageJson?: PackageJSON)

Source from the content-addressed store, hash-verified

56}
57
58export function getCorrectRegistry(packageJson?: PackageJSON): RegistryInfo {
59 const packageName = packageJson?.name;
60
61 if (packageName?.startsWith("@")) {
62 const scope = packageName.split("/")[0];
63 const scopedRegistry =
64 packageJson!.publishConfig?.[`${scope}:registry`] ||
65 process.env[`npm_config_${scope}:registry`];
66 if (scopedRegistry) {
67 return {
68 scope,
69 registry: scopedRegistry,
70 };
71 }
72 }
73
74 const registry =
75 packageJson?.publishConfig?.registry || process.env.npm_config_registry;
76
77 return {
78 scope: undefined,
79 registry:
80 !registry || !isCustomRegistry(registry) ? NPM_REGISTRY : registry,
81 };
82}
83
84async function getPublishTool(
85 cwd: string

Callers 5

getTwoFactorStateFunction · 0.90
npm-utils.test.tsFile · 0.90
getTokenIsRequiredFunction · 0.85
getPackageInfoFunction · 0.85
internalPublishFunction · 0.85

Calls 1

isCustomRegistryFunction · 0.85

Tested by

no test coverage detected