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
This commit is contained in:
Filip Skokan 2022-06-30 21:55:32 +02:00
parent 7d610f0c26
commit 3ac35dad40
2 changed files with 14 additions and 0 deletions

View file

@ -30,6 +30,8 @@ inputs:
outputs: outputs:
cache-hit: cache-hit:
description: 'A boolean value to indicate if a cache was hit.' description: 'A boolean value to indicate if a cache was hit.'
node-version:
description: 'The installed node version.'
runs: runs:
using: 'node16' using: 'node16'
main: 'dist/setup/index.js' main: 'dist/setup/index.js'

View file

@ -1,4 +1,5 @@
import * as core from '@actions/core'; import * as core from '@actions/core';
import * as exec from '@actions/exec';
import * as installer from './installer'; import * as installer from './installer';
import fs from 'fs'; import fs from 'fs';
import * as auth from './authutil'; import * as auth from './authutil';
@ -39,6 +40,17 @@ export async function run() {
await installer.getNode(version, stable, checkLatest, auth, arch); 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 registryUrl: string = core.getInput('registry-url');
const alwaysAuth: string = core.getInput('always-auth'); const alwaysAuth: string = core.getInput('always-auth');
if (registryUrl) { if (registryUrl) {