|
|
|
|
@ -11,13 +11,11 @@ const fs = __importStar(require("fs"));
|
|
|
|
|
const os = __importStar(require("os"));
|
|
|
|
|
const path = __importStar(require("path"));
|
|
|
|
|
const core = __importStar(require("@actions/core"));
|
|
|
|
|
function configAuth(registryUrl) {
|
|
|
|
|
let npmrc = path.resolve(process.cwd(), '.npmrc');
|
|
|
|
|
let yarnrc = path.resolve(process.cwd(), '.yarnrc');
|
|
|
|
|
function configAuthentication(registryUrl) {
|
|
|
|
|
const npmrc = path.resolve(process.cwd(), '.npmrc');
|
|
|
|
|
writeRegistryToFile(registryUrl, npmrc);
|
|
|
|
|
writeRegistryToFile(registryUrl, yarnrc);
|
|
|
|
|
}
|
|
|
|
|
exports.configAuth = configAuth;
|
|
|
|
|
exports.configAuthentication = configAuthentication;
|
|
|
|
|
function writeRegistryToFile(registryUrl, fileLocation) {
|
|
|
|
|
core.debug(`Setting auth in ${fileLocation}`);
|
|
|
|
|
let newContents = '';
|
|
|
|
|
@ -25,7 +23,7 @@ function writeRegistryToFile(registryUrl, fileLocation) {
|
|
|
|
|
const curContents = fs.readFileSync(fileLocation, 'utf8');
|
|
|
|
|
curContents.split(os.EOL).forEach((line) => {
|
|
|
|
|
// Add current contents unless they are setting the registry
|
|
|
|
|
if (!line.startsWith('registry')) {
|
|
|
|
|
if (!line.toLowerCase().startsWith('registry')) {
|
|
|
|
|
newContents += line + os.EOL;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
@ -36,7 +34,7 @@ function writeRegistryToFile(registryUrl, fileLocation) {
|
|
|
|
|
os.EOL +
|
|
|
|
|
'always-auth=true' +
|
|
|
|
|
os.EOL +
|
|
|
|
|
registryUrl.replace(/(^\w+:|^)/, '') +
|
|
|
|
|
registryUrl.replace(/(^\w+:|^)/, '') + // Remove http: or https: from front of registry.
|
|
|
|
|
':_authToken=${NODE_AUTH_TOKEN}';
|
|
|
|
|
fs.writeFileSync(fileLocation, newContents);
|
|
|
|
|
}
|
|
|
|
|
|