( /** 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, )
| 98 | } |
| 99 | |
| 100 | export 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 | } |
no test coverage detected