@@ -26,6 +26,7 @@ test.beforeEach(async t => {
26
26
delete process . env . NPM_USERNAME ;
27
27
delete process . env . NPM_PASSWORD ;
28
28
delete process . env . NPM_EMAIL ;
29
+ delete process . env . DEFAULT_NPM_REGISTRY ;
29
30
// Create a git repository, set the current working directory at the root of the repo
30
31
await gitRepo ( ) ;
31
32
await gitCommit ( 'Initial commit' ) ;
@@ -58,6 +59,7 @@ test.serial('Skip npm auth verification if "npmPublish" is false', async t => {
58
59
59
60
test . serial ( 'Throws error if NPM token is invalid' , async t => {
60
61
process . env . NPM_TOKEN = 'wrong_token' ;
62
+ process . env . DEFAULT_NPM_REGISTRY = npmRegistry . url ;
61
63
const pkg = { name : 'published' , version : '1.0.0' , publishConfig : { registry : npmRegistry . url } } ;
62
64
await outputJson ( './package.json' , pkg ) ;
63
65
const error = await t . throws ( t . context . m . verifyConditions ( { } , { options : { } , logger : t . context . logger } ) ) ;
@@ -70,10 +72,21 @@ test.serial('Throws error if NPM token is invalid', async t => {
70
72
t . regex ( npmrc , / : _ a u t h T o k e n / ) ;
71
73
} ) ;
72
74
75
+ test . serial ( 'Skip Token validation if the registry configured is not the default one' , async t => {
76
+ process . env . NPM_TOKEN = 'wrong_token' ;
77
+ const pkg = { name : 'published' , version : '1.0.0' , publishConfig : { registry : 'http://custom-registry.com/' } } ;
78
+ await outputJson ( './package.json' , pkg ) ;
79
+ await t . notThrows ( t . context . m . verifyConditions ( { } , { options : { } , logger : t . context . logger } ) ) ;
80
+
81
+ const npmrc = ( await readFile ( '.npmrc' ) ) . toString ( ) ;
82
+ t . regex ( npmrc , / : _ a u t h T o k e n / ) ;
83
+ } ) ;
84
+
73
85
test . serial (
74
86
'Throws error if NPM token is invalid if "npmPublish" is false and npm plugin used for "getLastRelease"' ,
75
87
async t => {
76
88
process . env . NPM_TOKEN = 'wrong_token' ;
89
+ process . env . DEFAULT_NPM_REGISTRY = npmRegistry . url ;
77
90
const pkg = { name : 'published' , version : '1.0.0' , publishConfig : { registry : npmRegistry . url } } ;
78
91
await outputJson ( './package.json' , pkg ) ;
79
92
const error = await t . throws (
@@ -96,6 +109,7 @@ test.serial(
96
109
'Throws error if NPM token is invalid if "npmPublish" is false and npm plugin used for "getLastRelease" as an object' ,
97
110
async t => {
98
111
process . env . NPM_TOKEN = 'wrong_token' ;
112
+ process . env . DEFAULT_NPM_REGISTRY = npmRegistry . url ;
99
113
const pkg = { name : 'published' , version : '1.0.0' , publishConfig : { registry : npmRegistry . url } } ;
100
114
await outputJson ( './package.json' , pkg ) ;
101
115
const error = await t . throws (
0 commit comments