From 3ac35dad40f9a0c4bd67c2056da725c9c35f73a4 Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Thu, 30 Jun 2022 21:55:32 +0200 Subject: [PATCH] This PR adds `node-version` to the action output. This is present in e.g. setup-python https://github.com/actions/setup-python/blob/main/action.yml closes #150 --- action.yml | 2 ++ src/main.ts | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/action.yml b/action.yml index 7bed73dc..a5e4877f 100644 --- a/action.yml +++ b/action.yml @@ -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' diff --git a/src/main.ts b/src/main.ts index 3c5661b5..106de77d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -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,17 @@ export async function run() { await installer.getNode(version, stable, checkLatest, auth, arch); } + // Output version of node is being used + let installedVersion = ''; + await exec.exec('node', ['--version'], { + listeners: { + stdout: data => { + installedVersion += data.toString(); + } + } + }); + core.setOutput('node-version', installedVersion); + const registryUrl: string = core.getInput('registry-url'); const alwaysAuth: string = core.getInput('always-auth'); if (registryUrl) {