mirror of
https://codeberg.org/actions/setup-node.git
synced 2023-07-31 13:16:24 +00:00
Add modification of scoped registry
This commit is contained in:
parent
3ae886ede4
commit
a69d45adcd
|
@ -29,7 +29,7 @@ function writeRegistryToFile(
|
||||||
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}`);
|
||||||
|
@ -38,7 +38,7 @@ function writeRegistryToFile(
|
||||||
const curContents: string = fs.readFileSync(fileLocation, 'utf8');
|
const curContents: string = fs.readFileSync(fileLocation, 'utf8');
|
||||||
curContents.split(os.EOL).forEach((line: string) => {
|
curContents.split(os.EOL).forEach((line: string) => {
|
||||||
// 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;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -46,9 +46,7 @@ function writeRegistryToFile(
|
||||||
// Remove http: or https: from front of registry.
|
// Remove http: or https: from front of registry.
|
||||||
const authString: string =
|
const authString: string =
|
||||||
registryUrl.replace(/(^\w+:|^)/, '') + ':_authToken=${NODE_AUTH_TOKEN}';
|
registryUrl.replace(/(^\w+:|^)/, '') + ':_authToken=${NODE_AUTH_TOKEN}';
|
||||||
const registryString: string = scope
|
const registryString: string = `${scope}registry=${registryUrl}`;
|
||||||
? `${scope}:registry=${registryUrl}`
|
|
||||||
: `registry=${registryUrl}`;
|
|
||||||
const alwaysAuthString: string = `always-auth=${alwaysAuth}`;
|
const alwaysAuthString: string = `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);
|
||||||
|
|
Loading…
Reference in a new issue