@@ -10,18 +10,17 @@ import * as npmRegistry from "./helpers/npm-registry.js";
1010/* eslint camelcase: ["error", {properties: "never"}] */
1111
1212// Environment variables used only for the local npm command used to do verification
13- const testEnv = {
14- ...process . env ,
15- ...npmRegistry . authEnv ,
16- npm_config_registry : npmRegistry . url ,
17- LEGACY_TOKEN : Buffer . from ( `${ npmRegistry . authEnv . NPM_USERNAME } :${ npmRegistry . authEnv . NPM_PASSWORD } ` , "utf8" ) . toString (
18- "base64"
19- ) ,
20- } ;
13+ let testEnv ;
2114
2215test . before ( async ( ) => {
2316 // Start the local NPM registry
2417 await npmRegistry . start ( ) ;
18+
19+ testEnv = {
20+ ...process . env ,
21+ ...npmRegistry . authEnv ( ) ,
22+ npm_config_registry : npmRegistry . url ,
23+ } ;
2524} ) ;
2625
2726test . after . always ( async ( ) => {
@@ -131,7 +130,7 @@ test("Verify npm auth and package", async (t) => {
131130 { } ,
132131 {
133132 cwd,
134- env : npmRegistry . authEnv ,
133+ env : npmRegistry . authEnv ( ) ,
135134 options : { } ,
136135 stdout : t . context . stdout ,
137136 stderr : t . context . stderr ,
@@ -150,7 +149,7 @@ test("Verify npm auth and package from a sub-directory", async (t) => {
150149 { pkgRoot : "dist" } ,
151150 {
152151 cwd,
153- env : npmRegistry . authEnv ,
152+ env : npmRegistry . authEnv ( ) ,
154153 options : { } ,
155154 stdout : t . context . stdout ,
156155 stderr : t . context . stderr ,
@@ -169,7 +168,7 @@ test('Verify npm auth and package with "npm_config_registry" env var set by yarn
169168 { } ,
170169 {
171170 cwd,
172- env : { ...npmRegistry . authEnv , npm_config_registry : "https://registry.yarnpkg.com" } ,
171+ env : { ...npmRegistry . authEnv ( ) , npm_config_registry : "https://registry.yarnpkg.com" } ,
173172 options : { publish : [ ] } ,
174173 stdout : t . context . stdout ,
175174 stderr : t . context . stderr ,
@@ -216,7 +215,7 @@ test("Throw SemanticReleaseError Array if config option are not valid in verifyC
216215
217216test ( "Publish the package" , async ( t ) => {
218217 const cwd = temporaryDirectory ( ) ;
219- const env = npmRegistry . authEnv ;
218+ const env = npmRegistry . authEnv ( ) ;
220219 const pkg = { name : "publish" , version : "0.0.0" , publishConfig : { registry : npmRegistry . url } } ;
221220 await fs . outputJson ( path . resolve ( cwd , "package.json" ) , pkg ) ;
222221
@@ -241,7 +240,7 @@ test("Publish the package", async (t) => {
241240
242241test ( "Publish the package on a dist-tag" , async ( t ) => {
243242 const cwd = temporaryDirectory ( ) ;
244- const env = { ...npmRegistry . authEnv , DEFAULT_NPM_REGISTRY : npmRegistry . url } ;
243+ const env = { ...npmRegistry . authEnv ( ) , DEFAULT_NPM_REGISTRY : npmRegistry . url } ;
245244 const pkg = { name : "publish-tag" , version : "0.0.0" , publishConfig : { registry : npmRegistry . url , tag : "next" } } ;
246245 await fs . outputJson ( path . resolve ( cwd , "package.json" ) , pkg ) ;
247246
@@ -270,7 +269,7 @@ test("Publish the package on a dist-tag", async (t) => {
270269
271270test ( "Publish the package from a sub-directory" , async ( t ) => {
272271 const cwd = temporaryDirectory ( ) ;
273- const env = npmRegistry . authEnv ;
272+ const env = npmRegistry . authEnv ( ) ;
274273 const pkg = { name : "publish-sub-dir" , version : "0.0.0" , publishConfig : { registry : npmRegistry . url } } ;
275274 await fs . outputJson ( path . resolve ( cwd , "dist/package.json" ) , pkg ) ;
276275
@@ -295,7 +294,7 @@ test("Publish the package from a sub-directory", async (t) => {
295294
296295test ( 'Create the package and skip publish ("npmPublish" is false)' , async ( t ) => {
297296 const cwd = temporaryDirectory ( ) ;
298- const env = npmRegistry . authEnv ;
297+ const env = npmRegistry . authEnv ( ) ;
299298 const pkg = { name : "skip-publish" , version : "0.0.0" , publishConfig : { registry : npmRegistry . url } } ;
300299 await fs . outputJson ( path . resolve ( cwd , "package.json" ) , pkg ) ;
301300
@@ -320,7 +319,7 @@ test('Create the package and skip publish ("npmPublish" is false)', async (t) =>
320319
321320test ( 'Create the package and skip publish ("package.private" is true)' , async ( t ) => {
322321 const cwd = temporaryDirectory ( ) ;
323- const env = npmRegistry . authEnv ;
322+ const env = npmRegistry . authEnv ( ) ;
324323 const pkg = {
325324 name : "skip-publish-private" ,
326325 version : "0.0.0" ,
@@ -350,7 +349,7 @@ test('Create the package and skip publish ("package.private" is true)', async (t
350349
351350test ( 'Create the package and skip publish from a sub-directory ("npmPublish" is false)' , async ( t ) => {
352351 const cwd = temporaryDirectory ( ) ;
353- const env = npmRegistry . authEnv ;
352+ const env = npmRegistry . authEnv ( ) ;
354353 const pkg = { name : "skip-publish-sub-dir" , version : "0.0.0" , publishConfig : { registry : npmRegistry . url } } ;
355354 await fs . outputJson ( path . resolve ( cwd , "dist/package.json" ) , pkg ) ;
356355
@@ -375,7 +374,7 @@ test('Create the package and skip publish from a sub-directory ("npmPublish" is
375374
376375test ( 'Create the package and skip publish from a sub-directory ("package.private" is true)' , async ( t ) => {
377376 const cwd = temporaryDirectory ( ) ;
378- const env = npmRegistry . authEnv ;
377+ const env = npmRegistry . authEnv ( ) ;
379378 const pkg = {
380379 name : "skip-publish-sub-dir-private" ,
381380 version : "0.0.0" ,
@@ -440,7 +439,7 @@ test("Throw SemanticReleaseError Array if config option are not valid in publish
440439
441440test ( "Prepare the package" , async ( t ) => {
442441 const cwd = temporaryDirectory ( ) ;
443- const env = npmRegistry . authEnv ;
442+ const env = npmRegistry . authEnv ( ) ;
444443 const pkg = { name : "prepare" , version : "0.0.0" , publishConfig : { registry : npmRegistry . url } } ;
445444 await fs . outputJson ( path . resolve ( cwd , "package.json" ) , pkg ) ;
446445
@@ -463,7 +462,7 @@ test("Prepare the package", async (t) => {
463462
464463test ( "Prepare the package from a sub-directory" , async ( t ) => {
465464 const cwd = temporaryDirectory ( ) ;
466- const env = npmRegistry . authEnv ;
465+ const env = npmRegistry . authEnv ( ) ;
467466 const pkg = { name : "prepare-sub-dir" , version : "0.0.0" , publishConfig : { registry : npmRegistry . url } } ;
468467 await fs . outputJson ( path . resolve ( cwd , "dist/package.json" ) , pkg ) ;
469468
@@ -521,7 +520,7 @@ test("Throw SemanticReleaseError Array if config option are not valid in prepare
521520
522521test ( "Publish the package and add to default dist-tag" , async ( t ) => {
523522 const cwd = temporaryDirectory ( ) ;
524- const env = npmRegistry . authEnv ;
523+ const env = npmRegistry . authEnv ( ) ;
525524 const pkg = { name : "add-channel" , version : "0.0.0" , publishConfig : { registry : npmRegistry . url } } ;
526525 await fs . outputJson ( path . resolve ( cwd , "package.json" ) , pkg ) ;
527526
@@ -557,7 +556,7 @@ test("Publish the package and add to default dist-tag", async (t) => {
557556
558557test ( "Publish the package and add to lts dist-tag" , async ( t ) => {
559558 const cwd = temporaryDirectory ( ) ;
560- const env = npmRegistry . authEnv ;
559+ const env = npmRegistry . authEnv ( ) ;
561560 const pkg = { name : "add-channel-legacy" , version : "1.0.0" , publishConfig : { registry : npmRegistry . url } } ;
562561 await fs . outputJson ( path . resolve ( cwd , "package.json" ) , pkg ) ;
563562
@@ -596,7 +595,7 @@ test("Publish the package and add to lts dist-tag", async (t) => {
596595
597596test ( 'Skip adding the package to a channel ("npmPublish" is false)' , async ( t ) => {
598597 const cwd = temporaryDirectory ( ) ;
599- const env = npmRegistry . authEnv ;
598+ const env = npmRegistry . authEnv ( ) ;
600599 const pkg = { name : "skip-add-channel" , version : "0.0.0" , publishConfig : { registry : npmRegistry . url } } ;
601600 await fs . outputJson ( path . resolve ( cwd , "package.json" ) , pkg ) ;
602601
@@ -619,7 +618,7 @@ test('Skip adding the package to a channel ("npmPublish" is false)', async (t) =
619618
620619test ( 'Skip adding the package to a channel ("package.private" is true)' , async ( t ) => {
621620 const cwd = temporaryDirectory ( ) ;
622- const env = npmRegistry . authEnv ;
621+ const env = npmRegistry . authEnv ( ) ;
623622 const pkg = {
624623 name : "skip-add-channel-private" ,
625624 version : "0.0.0" ,
@@ -647,7 +646,7 @@ test('Skip adding the package to a channel ("package.private" is true)', async (
647646
648647test ( "Create the package in addChannel step" , async ( t ) => {
649648 const cwd = temporaryDirectory ( ) ;
650- const env = npmRegistry . authEnv ;
649+ const env = npmRegistry . authEnv ( ) ;
651650 const pkg = { name : "add-channel-pkg" , version : "0.0.0" , publishConfig : { registry : npmRegistry . url } } ;
652651 await fs . outputJson ( path . resolve ( cwd , "package.json" ) , pkg ) ;
653652
@@ -670,7 +669,7 @@ test("Create the package in addChannel step", async (t) => {
670669
671670test ( "Throw SemanticReleaseError Array if config option are not valid in addChannel" , async ( t ) => {
672671 const cwd = temporaryDirectory ( ) ;
673- const env = npmRegistry . authEnv ;
672+ const env = npmRegistry . authEnv ( ) ;
674673 const pkg = { publishConfig : { registry : npmRegistry . url } } ;
675674 await fs . outputJson ( path . resolve ( cwd , "package.json" ) , pkg ) ;
676675 const npmPublish = 42 ;
@@ -706,7 +705,7 @@ test("Throw SemanticReleaseError Array if config option are not valid in addChan
706705
707706test ( "Verify token and set up auth only on the fist call, then prepare on prepare call only" , async ( t ) => {
708707 const cwd = temporaryDirectory ( ) ;
709- const env = npmRegistry . authEnv ;
708+ const env = npmRegistry . authEnv ( ) ;
710709 const pkg = { name : "test-module" , version : "0.0.0-dev" , publishConfig : { registry : npmRegistry . url } } ;
711710 await fs . outputJson ( path . resolve ( cwd , "package.json" ) , pkg ) ;
712711
0 commit comments