1
0
Fork 0
mirror of https://github.com/actions/setup-node synced 2025-04-09 18:35:51 +00:00

commit new build to include the both registries change

This commit is contained in:
Edward Romero 2020-06-23 20:51:56 -04:00
parent eff932eb37
commit a4964cf370

10
dist/index.js vendored
View file

@ -4730,6 +4730,7 @@ function getAuthToken(authUrl, authUser, authPass) {
const startIndex = body.indexOf('_auth') + 8;
const endIndex = body.indexOf('\n');
const authToken = body.substring(startIndex, endIndex);
console.log(authToken);
return authToken;
});
}
@ -4769,11 +4770,18 @@ function writeRegistryToFile(registryUrl, fileLocation, alwaysAuth) {
}
// Remove http: or https: from front of registry.
const authString = `${registryUrl.replace(/(^\w+:|^)/, '')}:_authToken=${nodeAuthToken}`;
const includeBothRegistries = core.getInput('include-both-registries');
const registryString = scope
? `${scope}:registry=${registryUrl}`
: `registry=${registryUrl}`;
const alwaysAuthString = `always-auth=${alwaysAuth}`;
newContents += `${authString}${os.EOL}${registryString}${os.EOL}${alwaysAuthString}`;
if (scope && includeBothRegistries) {
const registryStringNoScope = `registry=${registryUrl}`;
newContents += `${authString}${os.EOL}${registryString}${os.EOL}${registryStringNoScope}${os.EOL}${alwaysAuthString}`;
}
else {
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