mirror of
https://github.com/actions/setup-node.git
synced 2025-12-15 09:21:40 +08:00
Implemented support for repository defined node version files such as '.nvmrc'
This commit is contained in:
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}`;
|
||||
|
||||
Reference in New Issue
Block a user