From d43864199af832cee12602d0a94df40406209cbe Mon Sep 17 00:00:00 2001 From: "James M. Greene" Date: Wed, 21 Aug 2019 21:46:35 -0500 Subject: [PATCH] Force all scope names to be lowercased (#39) Fixes #38 --- __tests__/__snapshots__/authutil.test.ts.snap | 4 ++-- __tests__/authutil.test.ts | 2 +- lib/authutil.js | 3 +++ src/authutil.ts | 3 +++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/__tests__/__snapshots__/authutil.test.ts.snap b/__tests__/__snapshots__/authutil.test.ts.snap index 99174a67..3059617b 100644 --- a/__tests__/__snapshots__/authutil.test.ts.snap +++ b/__tests__/__snapshots__/authutil.test.ts.snap @@ -7,12 +7,12 @@ registry=https://registry.npmjs.org/" exports[`installer tests Automatically configures GPR scope 1`] = ` "npm.pkg.github.com/:_authToken=\${NODE_AUTH_TOKEN} -@owner:registry=npm.pkg.github.com/" +@ownername:registry=npm.pkg.github.com/" `; exports[`installer tests Configures scoped npm registries 1`] = ` "//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN} -@myScope:registry=https://registry.npmjs.org/" +@myscope:registry=https://registry.npmjs.org/" `; exports[`installer tests Sets up npmrc for npmjs 1`] = ` diff --git a/__tests__/authutil.test.ts b/__tests__/authutil.test.ts index 3dab9078..2e88011e 100644 --- a/__tests__/authutil.test.ts +++ b/__tests__/authutil.test.ts @@ -15,7 +15,7 @@ const tempDir = path.join( const rcFile = path.join(tempDir, '.npmrc'); -process.env['GITHUB_REPOSITORY'] = 'owner/repo'; +process.env['GITHUB_REPOSITORY'] = 'OwnerName/repo'; process.env['RUNNER_TEMP'] = tempDir; import * as auth from '../src/authutil'; diff --git a/lib/authutil.js b/lib/authutil.js index d428b4e4..bb85fff3 100644 --- a/lib/authutil.js +++ b/lib/authutil.js @@ -28,6 +28,9 @@ function writeRegistryToFile(registryUrl, fileLocation) { if (scope && scope[0] != '@') { scope = '@' + scope; } + if (scope) { + scope = scope.toLowerCase(); + } core.debug(`Setting auth in ${fileLocation}`); let newContents = ''; if (fs.existsSync(fileLocation)) { diff --git a/src/authutil.ts b/src/authutil.ts index c896339c..99f78efe 100644 --- a/src/authutil.ts +++ b/src/authutil.ts @@ -24,6 +24,9 @@ function writeRegistryToFile(registryUrl: string, fileLocation: string) { if (scope && scope[0] != '@') { scope = '@' + scope; } + if (scope) { + scope = scope.toLowerCase(); + } core.debug(`Setting auth in ${fileLocation}`); let newContents: string = '';