Yarn sometimes prefers npmrc, so use same token

This commit is contained in:
Danny McCormick 2019-08-05 11:57:53 -04:00
parent 287437bd45
commit 9776256210
2 changed files with 8 additions and 16 deletions

View file

@ -14,11 +14,11 @@ const core = __importStar(require("@actions/core"));
function configAuth(registryUrl) {
let npmrc = path.resolve(process.cwd(), '.npmrc');
let yarnrc = path.resolve(process.cwd(), '.yarnrc');
writeRegistryToFile(registryUrl, npmrc, 'NPM_TOKEN');
writeRegistryToFile(registryUrl, yarnrc, 'YARN_TOKEN');
writeRegistryToFile(registryUrl, npmrc);
writeRegistryToFile(registryUrl, yarnrc);
}
exports.configAuth = configAuth;
function writeRegistryToFile(registryUrl, fileLocation, authTokenName) {
function writeRegistryToFile(registryUrl, fileLocation) {
core.debug(`Setting auth in ${fileLocation}`);
let newContents = '';
if (fs.existsSync(fileLocation)) {
@ -37,8 +37,6 @@ function writeRegistryToFile(registryUrl, fileLocation, authTokenName) {
'always-auth=true' +
os.EOL +
registryUrl.replace(/(^\w+:|^)/, '') +
':_authToken=${' +
authTokenName +
'}';
':_authToken=${NODE_AUTH_TOKEN}';
fs.writeFileSync(fileLocation, newContents);
}