Add modification of scoped registry

This commit is contained in:
Sergey Dolin 2022-12-05 13:32:26 +01:00
parent 3ae886ede4
commit a69d45adcd

View file

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