mirror of
				https://kkgithub.com/actions/setup-node.git
				synced 2025-10-31 18:51:54 +08:00 
			
		
		
		
	Add setting for always-auth (#48)
* Add setting for always-auth - https://docs.npmjs.com/misc/config#always-auth - Allow private repos for stuff like artifactory to work * Fix tests for always-auth
This commit is contained in:
		 David J. Felix
					David J. Felix
				
			
				
					committed by
					
						 Danny McCormick
						Danny McCormick
					
				
			
			
				
	
			
			
			 Danny McCormick
						Danny McCormick
					
				
			
						parent
						
							57adacb752
						
					
				
				
					commit
					7a3ce83626
				
			| @ -12,15 +12,15 @@ const os = __importStar(require("os")); | ||||
| const path = __importStar(require("path")); | ||||
| const core = __importStar(require("@actions/core")); | ||||
| const github = __importStar(require("@actions/github")); | ||||
| function configAuthentication(registryUrl) { | ||||
| function configAuthentication(registryUrl, alwaysAuth) { | ||||
|     const npmrc = path.resolve(process.env['RUNNER_TEMP'] || process.cwd(), '.npmrc'); | ||||
|     if (!registryUrl.endsWith('/')) { | ||||
|         registryUrl += '/'; | ||||
|     } | ||||
|     writeRegistryToFile(registryUrl, npmrc); | ||||
|     writeRegistryToFile(registryUrl, npmrc, alwaysAuth); | ||||
| } | ||||
| exports.configAuthentication = configAuthentication; | ||||
| function writeRegistryToFile(registryUrl, fileLocation) { | ||||
| function writeRegistryToFile(registryUrl, fileLocation, alwaysAuth) { | ||||
|     let scope = core.getInput('scope'); | ||||
|     if (!scope && registryUrl.indexOf('npm.pkg.github.com') > -1) { | ||||
|         scope = github.context.repo.owner; | ||||
| @ -47,7 +47,8 @@ function writeRegistryToFile(registryUrl, fileLocation) { | ||||
|     const registryString = scope | ||||
|         ? `${scope}:registry=${registryUrl}` | ||||
|         : `registry=${registryUrl}`; | ||||
|     newContents += `${authString}${os.EOL}${registryString}`; | ||||
|     const alwaysAuthString = `always-auth=${alwaysAuth}`; | ||||
|     newContents += `${authString}${os.EOL}${registryString}${os.EOL}${alwaysAuthString}`; | ||||
|     fs.writeFileSync(fileLocation, newContents); | ||||
|     core.exportVariable('NPM_CONFIG_USERCONFIG', fileLocation); | ||||
|     // Export empty node_auth_token so npm doesn't complain about not being able to find it | ||||
|  | ||||
| @ -35,8 +35,9 @@ function run() { | ||||
|                 yield installer.getNode(version); | ||||
|             } | ||||
|             const registryUrl = core.getInput('registry-url'); | ||||
|             const alwaysAuth = core.getInput('always-auth'); | ||||
|             if (registryUrl) { | ||||
|                 auth.configAuthentication(registryUrl); | ||||
|                 auth.configAuthentication(registryUrl, alwaysAuth); | ||||
|             } | ||||
|             // TODO: setup proxy from runner proxy config | ||||
|             const matchersPath = path.join(__dirname, '..', '.github'); | ||||
|  | ||||
		Reference in New Issue
	
	Block a user