MCPcopy Index your code
hub / github.com/angular/angular-cli / setNpmEnvVarsForAuthentication

Function setNpmEnvVarsForAuthentication

tests/e2e/utils/registry.ts:100–117  ·  view source on GitHub ↗
(
  /** When true, an incorrect token is used. Use this to validate authentication failures. */
  invalidToken = false,
  /** When true, `YARN_REGISTRY` is used instead of `NPM_CONFIG_REGISTRY`. */
  useYarnEnvVariable = false,
)

Source from the content-addressed store, hash-verified

98}
99
100export function setNpmEnvVarsForAuthentication(
101 /** When true, an incorrect token is used. Use this to validate authentication failures. */
102 invalidToken = false,
103 /** When true, `YARN_REGISTRY` is used instead of `NPM_CONFIG_REGISTRY`. */
104 useYarnEnvVariable = false,
105): void {
106 delete process.env['YARN_REGISTRY'];
107 delete process.env['NPM_CONFIG_REGISTRY'];
108
109 const registryKey = useYarnEnvVariable ? 'YARN_REGISTRY' : 'NPM_CONFIG_REGISTRY';
110 process.env[registryKey] = getGlobalVariable('package-secure-registry');
111
112 process.env['NPM_CONFIG__AUTH'] = invalidToken ? `invalid=` : VALID_TOKEN;
113
114 // Needed for verdaccio when used with yarn
115 // https://verdaccio.org/docs/en/cli-registry#yarn
116 process.env['NPM_CONFIG_ALWAYS_AUTH'] = 'true';
117}

Callers 1

yarn-env-vars.tsFile · 0.90

Calls 1

getGlobalVariableFunction · 0.90

Tested by

no test coverage detected