From f5faff30bb37000bc14576a18cf617d41704003d Mon Sep 17 00:00:00 2001 From: Edward Romero Date: Tue, 23 Jun 2020 20:56:51 -0400 Subject: [PATCH] add node auth token env --- dist/index.js | 12 +++++++++--- src/authutil.ts | 11 ++++++++--- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/dist/index.js b/dist/index.js index a6042b58..d0a48d60 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4758,7 +4758,8 @@ function writeRegistryToFile(registryUrl, fileLocation, alwaysAuth) { } }); } - let nodeAuthToken = '${NODE_AUTH_TOKEN}'; + let defaultNodeAuthToken = '${NODE_AUTH_TOKEN}'; + let nodeAuthToken = defaultNodeAuthToken; // Check if auth url provided const authUrl = core.getInput('auth-url'); if (authUrl) { @@ -4784,8 +4785,13 @@ function writeRegistryToFile(registryUrl, fileLocation, alwaysAuth) { } fs.writeFileSync(fileLocation, newContents); core.exportVariable('NPM_CONFIG_USERCONFIG', fileLocation); - // Export empty node_auth_token so npm doesn't complain about not being able to find it - core.exportVariable('NODE_AUTH_TOKEN', 'XXXXX-XXXXX-XXXXX-XXXXX'); + if (defaultNodeAuthToken !== nodeAuthToken) { + core.exportVariable('NODE_AUTH_TOKEN', nodeAuthToken); + } + else { + // Export empty node_auth_token so npm doesn't complain about not being able to find it + core.exportVariable('NODE_AUTH_TOKEN', 'XXXXX-XXXXX-XXXXX-XXXXX'); + } }); } //# sourceMappingURL=authutil.js.map diff --git a/src/authutil.ts b/src/authutil.ts index c43eb1d1..3ca8e157 100644 --- a/src/authutil.ts +++ b/src/authutil.ts @@ -76,7 +76,8 @@ async function writeRegistryToFile( }); } - let nodeAuthToken = '${NODE_AUTH_TOKEN}'; + let defaultNodeAuthToken = '${NODE_AUTH_TOKEN}'; + let nodeAuthToken = defaultNodeAuthToken; // Check if auth url provided const authUrl: string = core.getInput('auth-url'); if (authUrl) { @@ -108,6 +109,10 @@ async function writeRegistryToFile( fs.writeFileSync(fileLocation, newContents); core.exportVariable('NPM_CONFIG_USERCONFIG', fileLocation); - // Export empty node_auth_token so npm doesn't complain about not being able to find it - core.exportVariable('NODE_AUTH_TOKEN', 'XXXXX-XXXXX-XXXXX-XXXXX'); + if (defaultNodeAuthToken !== nodeAuthToken) { + core.exportVariable('NODE_AUTH_TOKEN', nodeAuthToken) + } else { + // Export empty node_auth_token so npm doesn't complain about not being able to find it + core.exportVariable('NODE_AUTH_TOKEN', 'XXXXX-XXXXX-XXXXX-XXXXX'); + } }