mirror of https://github.com/actions/setup-node
Merge pull request #534 from panva/set-version-output
set node-version output (2022 edition)
This commit is contained in:
commit
78faa555e1
|
@ -1,6 +1,7 @@
|
|||
import * as core from '@actions/core';
|
||||
import * as io from '@actions/io';
|
||||
import * as tc from '@actions/tool-cache';
|
||||
import * as exec from '@actions/exec';
|
||||
import * as im from '../src/installer';
|
||||
import * as cache from '@actions/cache';
|
||||
import fs from 'fs';
|
||||
|
@ -38,6 +39,7 @@ describe('setup-node', () => {
|
|||
let authSpy: jest.SpyInstance;
|
||||
let parseNodeVersionSpy: jest.SpyInstance;
|
||||
let isCacheActionAvailable: jest.SpyInstance;
|
||||
let getExecOutputSpy: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
// @actions/core
|
||||
|
@ -103,6 +105,10 @@ describe('setup-node', () => {
|
|||
// uncomment to debug
|
||||
// process.stderr.write('log:' + line + '\n');
|
||||
});
|
||||
|
||||
// @actions/exec
|
||||
getExecOutputSpy = jest.spyOn(exec, 'getExecOutput');
|
||||
getExecOutputSpy.mockImplementation(() => 'v16.15.0');
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
|
|
|
@ -30,6 +30,8 @@ inputs:
|
|||
outputs:
|
||||
cache-hit:
|
||||
description: 'A boolean value to indicate if a cache was hit.'
|
||||
node-version:
|
||||
description: 'The installed node version.'
|
||||
runs:
|
||||
using: 'node16'
|
||||
main: 'dist/setup/index.js'
|
||||
|
|
|
@ -71808,6 +71808,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
const core = __importStar(__nccwpck_require__(2186));
|
||||
const exec = __importStar(__nccwpck_require__(1514));
|
||||
const installer = __importStar(__nccwpck_require__(2574));
|
||||
const fs_1 = __importDefault(__nccwpck_require__(7147));
|
||||
const auth = __importStar(__nccwpck_require__(7573));
|
||||
|
@ -71840,6 +71841,9 @@ function run() {
|
|||
const checkLatest = (core.getInput('check-latest') || 'false').toUpperCase() === 'TRUE';
|
||||
yield installer.getNode(version, stable, checkLatest, auth, arch);
|
||||
}
|
||||
// Output version of node is being used
|
||||
const { stdout: installedVersion } = yield exec.getExecOutput('node', ['--version'], { ignoreReturnCode: true });
|
||||
core.setOutput('node-version', installedVersion);
|
||||
const registryUrl = core.getInput('registry-url');
|
||||
const alwaysAuth = core.getInput('always-auth');
|
||||
if (registryUrl) {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import * as core from '@actions/core';
|
||||
import * as exec from '@actions/exec';
|
||||
import * as installer from './installer';
|
||||
import fs from 'fs';
|
||||
import * as auth from './authutil';
|
||||
|
@ -39,6 +40,14 @@ export async function run() {
|
|||
await installer.getNode(version, stable, checkLatest, auth, arch);
|
||||
}
|
||||
|
||||
// Output version of node is being used
|
||||
const {stdout: installedVersion} = await exec.getExecOutput(
|
||||
'node',
|
||||
['--version'],
|
||||
{ignoreReturnCode: true}
|
||||
);
|
||||
core.setOutput('node-version', installedVersion);
|
||||
|
||||
const registryUrl: string = core.getInput('registry-url');
|
||||
const alwaysAuth: string = core.getInput('always-auth');
|
||||
if (registryUrl) {
|
||||
|
|
Loading…
Reference in New Issue