3
0
Fork 0
mirror of https://gitea.com/actions/setup-node.git synced 2024-11-25 11:39:32 +01:00
This commit is contained in:
Sergey Dolin 2022-12-05 13:37:05 +01:00
parent e77eaaccd3
commit 069a4f8926

8
dist/setup/index.js vendored
View file

@ -72945,7 +72945,7 @@ function writeRegistryToFile(registryUrl, fileLocation, alwaysAuth) {
scope = '@' + scope; scope = '@' + scope;
} }
if (scope) { if (scope) {
scope = scope.toLowerCase(); scope = scope.toLowerCase() + ':';
} }
core.debug(`Setting auth in ${fileLocation}`); core.debug(`Setting auth in ${fileLocation}`);
let newContents = ''; let newContents = '';
@ -72953,16 +72953,14 @@ function writeRegistryToFile(registryUrl, fileLocation, alwaysAuth) {
const curContents = fs.readFileSync(fileLocation, 'utf8'); const curContents = fs.readFileSync(fileLocation, 'utf8');
curContents.split(os.EOL).forEach((line) => { curContents.split(os.EOL).forEach((line) => {
// Add current contents unless they are setting the registry // Add current contents unless they are setting the registry
if (!line.toLowerCase().startsWith('registry')) { if (!line.toLowerCase().startsWith(`${scope}registry`)) {
newContents += line + os.EOL; newContents += line + os.EOL;
} }
}); });
} }
// Remove http: or https: from front of registry. // Remove http: or https: from front of registry.
const authString = registryUrl.replace(/(^\w+:|^)/, '') + ':_authToken=${NODE_AUTH_TOKEN}'; const authString = registryUrl.replace(/(^\w+:|^)/, '') + ':_authToken=${NODE_AUTH_TOKEN}';
const registryString = scope const registryString = `${scope}registry=${registryUrl}`;
? `${scope}:registry=${registryUrl}`
: `registry=${registryUrl}`;
const alwaysAuthString = `always-auth=${alwaysAuth}`; const alwaysAuthString = `always-auth=${alwaysAuth}`;
newContents += `${authString}${os.EOL}${registryString}${os.EOL}${alwaysAuthString}`; newContents += `${authString}${os.EOL}${registryString}${os.EOL}${alwaysAuthString}`;
fs.writeFileSync(fileLocation, newContents); fs.writeFileSync(fileLocation, newContents);