mirror of
				https://gitea.com/actions/setup-node.git
				synced 2025-10-29 07:47:20 +00:00 
			
		
		
		
	Yarn sometimes prefers npmrc, so use same token
This commit is contained in:
		| @@ -14,11 +14,11 @@ const core = __importStar(require("@actions/core")); | |||||||
| function configAuth(registryUrl) { | function configAuth(registryUrl) { | ||||||
|     let npmrc = path.resolve(process.cwd(), '.npmrc'); |     let npmrc = path.resolve(process.cwd(), '.npmrc'); | ||||||
|     let yarnrc = path.resolve(process.cwd(), '.yarnrc'); |     let yarnrc = path.resolve(process.cwd(), '.yarnrc'); | ||||||
|     writeRegistryToFile(registryUrl, npmrc, 'NPM_TOKEN'); |     writeRegistryToFile(registryUrl, npmrc); | ||||||
|     writeRegistryToFile(registryUrl, yarnrc, 'YARN_TOKEN'); |     writeRegistryToFile(registryUrl, yarnrc); | ||||||
| } | } | ||||||
| exports.configAuth = configAuth; | exports.configAuth = configAuth; | ||||||
| function writeRegistryToFile(registryUrl, fileLocation, authTokenName) { | function writeRegistryToFile(registryUrl, fileLocation) { | ||||||
|     core.debug(`Setting auth in ${fileLocation}`); |     core.debug(`Setting auth in ${fileLocation}`); | ||||||
|     let newContents = ''; |     let newContents = ''; | ||||||
|     if (fs.existsSync(fileLocation)) { |     if (fs.existsSync(fileLocation)) { | ||||||
| @@ -37,8 +37,6 @@ function writeRegistryToFile(registryUrl, fileLocation, authTokenName) { | |||||||
|             'always-auth=true' + |             'always-auth=true' + | ||||||
|             os.EOL + |             os.EOL + | ||||||
|             registryUrl.replace(/(^\w+:|^)/, '') + |             registryUrl.replace(/(^\w+:|^)/, '') + | ||||||
|             ':_authToken=${' + |             ':_authToken=${NODE_AUTH_TOKEN}'; | ||||||
|             authTokenName + |  | ||||||
|             '}'; |  | ||||||
|     fs.writeFileSync(fileLocation, newContents); |     fs.writeFileSync(fileLocation, newContents); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -7,15 +7,11 @@ export function configAuth(registryUrl: string) { | |||||||
|   let npmrc: string = path.resolve(process.cwd(), '.npmrc'); |   let npmrc: string = path.resolve(process.cwd(), '.npmrc'); | ||||||
|   let yarnrc: string = path.resolve(process.cwd(), '.yarnrc'); |   let yarnrc: string = path.resolve(process.cwd(), '.yarnrc'); | ||||||
|  |  | ||||||
|   writeRegistryToFile(registryUrl, npmrc, 'NPM_TOKEN'); |   writeRegistryToFile(registryUrl, npmrc); | ||||||
|   writeRegistryToFile(registryUrl, yarnrc, 'YARN_TOKEN'); |   writeRegistryToFile(registryUrl, yarnrc); | ||||||
| } | } | ||||||
|  |  | ||||||
| function writeRegistryToFile( | function writeRegistryToFile(registryUrl: string, fileLocation: string) { | ||||||
|   registryUrl: string, |  | ||||||
|   fileLocation: string, |  | ||||||
|   authTokenName: string |  | ||||||
| ) { |  | ||||||
|   core.debug(`Setting auth in ${fileLocation}`); |   core.debug(`Setting auth in ${fileLocation}`); | ||||||
|   let newContents = ''; |   let newContents = ''; | ||||||
|   if (fs.existsSync(fileLocation)) { |   if (fs.existsSync(fileLocation)) { | ||||||
| @@ -34,8 +30,6 @@ function writeRegistryToFile( | |||||||
|     'always-auth=true' + |     'always-auth=true' + | ||||||
|     os.EOL + |     os.EOL + | ||||||
|     registryUrl.replace(/(^\w+:|^)/, '') + |     registryUrl.replace(/(^\w+:|^)/, '') + | ||||||
|     ':_authToken=${' + |     ':_authToken=${NODE_AUTH_TOKEN}'; | ||||||
|     authTokenName + |  | ||||||
|     '}'; |  | ||||||
|   fs.writeFileSync(fileLocation, newContents); |   fs.writeFileSync(fileLocation, newContents); | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Danny McCormick
					Danny McCormick