add node auth token env

This commit is contained in:
Edward Romero 2020-06-23 20:56:51 -04:00
parent a4964cf370
commit f5faff30bb
2 changed files with 17 additions and 6 deletions

12
dist/index.js vendored
View File

@ -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 // Check if auth url provided
const authUrl = core.getInput('auth-url'); const authUrl = core.getInput('auth-url');
if (authUrl) { if (authUrl) {
@ -4784,8 +4785,13 @@ function writeRegistryToFile(registryUrl, fileLocation, alwaysAuth) {
} }
fs.writeFileSync(fileLocation, newContents); fs.writeFileSync(fileLocation, newContents);
core.exportVariable('NPM_CONFIG_USERCONFIG', fileLocation); core.exportVariable('NPM_CONFIG_USERCONFIG', fileLocation);
// Export empty node_auth_token so npm doesn't complain about not being able to find it if (defaultNodeAuthToken !== nodeAuthToken) {
core.exportVariable('NODE_AUTH_TOKEN', 'XXXXX-XXXXX-XXXXX-XXXXX'); 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 //# sourceMappingURL=authutil.js.map

View File

@ -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 // Check if auth url provided
const authUrl: string = core.getInput('auth-url'); const authUrl: string = core.getInput('auth-url');
if (authUrl) { if (authUrl) {
@ -108,6 +109,10 @@ async function writeRegistryToFile(
fs.writeFileSync(fileLocation, newContents); fs.writeFileSync(fileLocation, newContents);
core.exportVariable('NPM_CONFIG_USERCONFIG', fileLocation); core.exportVariable('NPM_CONFIG_USERCONFIG', fileLocation);
// Export empty node_auth_token so npm doesn't complain about not being able to find it if (defaultNodeAuthToken !== nodeAuthToken) {
core.exportVariable('NODE_AUTH_TOKEN', 'XXXXX-XXXXX-XXXXX-XXXXX'); 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');
}
} }