mirror of
https://github.com/actions/setup-node.git
synced 2025-07-04 08:33:47 +00:00
Implemented support for repository defined node version files such as '.nvmrc'
This commit is contained in:
parent
c6fd00ceb9
commit
c3812bd36a
5 changed files with 83 additions and 0 deletions
11
src/main.ts
11
src/main.ts
|
@ -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}`;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue