@@ -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
2417await 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 ( ) ,
135134options :{ } ,
136135stdout :t . context . stdout ,
137136stderr :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 ( ) ,
154153options :{ } ,
155154stdout :t . context . stdout ,
156155stderr :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" } ,
173172options :{ publish :[ ] } ,
174173stdout :t . context . stdout ,
175174stderr :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 ) => {
218217const cwd = temporaryDirectory ( ) ;
219- const env = npmRegistry . authEnv ;
218+ const env = npmRegistry . authEnv ( ) ;
220219const pkg = { name :"publish" , version :"0.0.0" , publishConfig :{ registry :npmRegistry . url } } ;
221220await 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 ) => {
243242const cwd = temporaryDirectory ( ) ;
244- const env = { ...npmRegistry . authEnv , DEFAULT_NPM_REGISTRY :npmRegistry . url } ;
243+ const env = { ...npmRegistry . authEnv ( ) , DEFAULT_NPM_REGISTRY :npmRegistry . url } ;
245244const pkg = { name :"publish-tag" , version :"0.0.0" , publishConfig :{ registry :npmRegistry . url , tag :"next" } } ;
246245await 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 ) => {
272271const cwd = temporaryDirectory ( ) ;
273- const env = npmRegistry . authEnv ;
272+ const env = npmRegistry . authEnv ( ) ;
274273const pkg = { name :"publish-sub-dir" , version :"0.0.0" , publishConfig :{ registry :npmRegistry . url } } ;
275274await 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 ) => {
297296const cwd = temporaryDirectory ( ) ;
298- const env = npmRegistry . authEnv ;
297+ const env = npmRegistry . authEnv ( ) ;
299298const pkg = { name :"skip-publish" , version :"0.0.0" , publishConfig :{ registry :npmRegistry . url } } ;
300299await 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 ) => {
322321const cwd = temporaryDirectory ( ) ;
323- const env = npmRegistry . authEnv ;
322+ const env = npmRegistry . authEnv ( ) ;
324323const pkg = {
325324name :"skip-publish-private" ,
326325version :"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 ) => {
352351const cwd = temporaryDirectory ( ) ;
353- const env = npmRegistry . authEnv ;
352+ const env = npmRegistry . authEnv ( ) ;
354353const pkg = { name :"skip-publish-sub-dir" , version :"0.0.0" , publishConfig :{ registry :npmRegistry . url } } ;
355354await 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 ) => {
377376const cwd = temporaryDirectory ( ) ;
378- const env = npmRegistry . authEnv ;
377+ const env = npmRegistry . authEnv ( ) ;
379378const pkg = {
380379name :"skip-publish-sub-dir-private" ,
381380version :"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 ) => {
442441const cwd = temporaryDirectory ( ) ;
443- const env = npmRegistry . authEnv ;
442+ const env = npmRegistry . authEnv ( ) ;
444443const pkg = { name :"prepare" , version :"0.0.0" , publishConfig :{ registry :npmRegistry . url } } ;
445444await 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 ) => {
465464const cwd = temporaryDirectory ( ) ;
466- const env = npmRegistry . authEnv ;
465+ const env = npmRegistry . authEnv ( ) ;
467466const pkg = { name :"prepare-sub-dir" , version :"0.0.0" , publishConfig :{ registry :npmRegistry . url } } ;
468467await 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 ) => {
523522const cwd = temporaryDirectory ( ) ;
524- const env = npmRegistry . authEnv ;
523+ const env = npmRegistry . authEnv ( ) ;
525524const pkg = { name :"add-channel" , version :"0.0.0" , publishConfig :{ registry :npmRegistry . url } } ;
526525await 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 ) => {
559558const cwd = temporaryDirectory ( ) ;
560- const env = npmRegistry . authEnv ;
559+ const env = npmRegistry . authEnv ( ) ;
561560const pkg = { name :"add-channel-legacy" , version :"1.0.0" , publishConfig :{ registry :npmRegistry . url } } ;
562561await 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 ) => {
598597const cwd = temporaryDirectory ( ) ;
599- const env = npmRegistry . authEnv ;
598+ const env = npmRegistry . authEnv ( ) ;
600599const pkg = { name :"skip-add-channel" , version :"0.0.0" , publishConfig :{ registry :npmRegistry . url } } ;
601600await 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 ) => {
621620const cwd = temporaryDirectory ( ) ;
622- const env = npmRegistry . authEnv ;
621+ const env = npmRegistry . authEnv ( ) ;
623622const pkg = {
624623name :"skip-add-channel-private" ,
625624version :"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 ) => {
649648const cwd = temporaryDirectory ( ) ;
650- const env = npmRegistry . authEnv ;
649+ const env = npmRegistry . authEnv ( ) ;
651650const pkg = { name :"add-channel-pkg" , version :"0.0.0" , publishConfig :{ registry :npmRegistry . url } } ;
652651await 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 ) => {
672671const cwd = temporaryDirectory ( ) ;
673- const env = npmRegistry . authEnv ;
672+ const env = npmRegistry . authEnv ( ) ;
674673const pkg = { publishConfig :{ registry :npmRegistry . url } } ;
675674await fs . outputJson ( path . resolve ( cwd , "package.json" ) , pkg ) ;
676675const 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 ) => {
708707const cwd = temporaryDirectory ( ) ;
709- const env = npmRegistry . authEnv ;
708+ const env = npmRegistry . authEnv ( ) ;
710709const pkg = { name :"test-module" , version :"0.0.0-dev" , publishConfig :{ registry :npmRegistry . url } } ;
711710await fs . outputJson ( path . resolve ( cwd , "package.json" ) , pkg ) ;
712711