This commit is contained in:
Danny McCormick 2019-08-05 13:12:37 -04:00
parent 8e12aec29e
commit 920661f1be
5 changed files with 15 additions and 18 deletions

View file

@ -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);
}

View file

@ -33,7 +33,7 @@ function run() {
}
const registryUrl = core.getInput('registry-url');
if (registryUrl) {
auth.configAuth(registryUrl);
auth.configAuthentication(registryUrl);
}
// TODO: setup proxy from runner proxy config
const matchersPath = path.join(__dirname, '..', '.github');