From 20a965d27f57569053773c979118e4b3b5d97514 Mon Sep 17 00:00:00 2001 From: Jason Karns Date: Sun, 29 Mar 2020 16:28:34 -0400 Subject: [PATCH 1/2] Spike to default the scope from package.json --- src/authutil.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/authutil.ts b/src/authutil.ts index aaebdfd2..c46166a5 100644 --- a/src/authutil.ts +++ b/src/authutil.ts @@ -25,6 +25,9 @@ function writeRegistryToFile( if (!scope && registryUrl.indexOf('npm.pkg.github.com') > -1) { scope = github.context.repo.owner; } + if (!scope && namePrefix = require('./package').name.match('@[^/]+')) { + scope = namePrefix[0]; + } if (scope && scope[0] != '@') { scope = '@' + scope; } From 094c1c12f46301181dbfaef16620668fa091de05 Mon Sep 17 00:00:00 2001 From: Jason Karns Date: Sun, 7 Feb 2021 10:28:55 -0500 Subject: [PATCH 2/2] Make linter happy --- src/authutil.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/authutil.ts b/src/authutil.ts index c46166a5..1dff201f 100644 --- a/src/authutil.ts +++ b/src/authutil.ts @@ -25,8 +25,11 @@ function writeRegistryToFile( if (!scope && registryUrl.indexOf('npm.pkg.github.com') > -1) { scope = github.context.repo.owner; } - if (!scope && namePrefix = require('./package').name.match('@[^/]+')) { - scope = namePrefix[0]; + if (!scope) { + let namePrefix = require('./package').name.match('@[^/]+'); + if (namePrefix) { + scope = namePrefix[0]; + } } if (scope && scope[0] != '@') { scope = '@' + scope;