Implemented support for repository defined node version files such as '.nvmrc'

This commit is contained in:
Taylor McCarthy 2020-11-01 17:04:22 -05:00
parent c6fd00ceb9
commit c3812bd36a
5 changed files with 83 additions and 0 deletions

View file

@ -1,6 +1,7 @@
import * as core from '@actions/core';
import * as installer from './installer';
import * as auth from './authutil';
import fs = require('fs');
import * as path from 'path';
import {URL} from 'url';
@ -15,6 +16,16 @@ export async function run() {
version = core.getInput('version');
}
if (!version) {
const versionFile = core.getInput('node-version-file');
if (!!versionFile) {
const versionFilePath = path.join(__dirname, '..', versionFile);
version = fs.readFileSync(versionFilePath, 'utf8');
core.info(`Resolved ${versionFile} as ${version}`);
}
}
if (version) {
let token = core.getInput('token');
let auth = !token || isGhes() ? undefined : `token ${token}`;