From a69d45adcd128d92db46d8cc7245c2237b41520b Mon Sep 17 00:00:00 2001 From: Sergey Dolin Date: Mon, 5 Dec 2022 13:32:26 +0100 Subject: [PATCH] Add modification of scoped registry --- src/authutil.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/authutil.ts b/src/authutil.ts index aaebdfd2..d1885482 100644 --- a/src/authutil.ts +++ b/src/authutil.ts @@ -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);