Skip to content

Commit 3ac35da

Browse files
committed
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
1 parent 7d610f0 commit 3ac35da

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

action.yml

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ inputs:
3030
outputs:
3131
cache-hit:
3232
description: 'A boolean value to indicate if a cache was hit.'
33+
node-version:
34+
description: 'The installed node version.'
3335
runs:
3436
using: 'node16'
3537
main: 'dist/setup/index.js'

src/main.ts

+12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as core from '@actions/core';
2+
import * as exec from '@actions/exec';
23
import * as installer from './installer';
34
import fs from 'fs';
45
import * as auth from './authutil';
@@ -39,6 +40,17 @@ export async function run() {
3940
await installer.getNode(version, stable, checkLatest, auth, arch);
4041
}
4142

43+
// Output version of node is being used
44+
let installedVersion = '';
45+
await exec.exec('node', ['--version'], {
46+
listeners: {
47+
stdout: data => {
48+
installedVersion += data.toString();
49+
}
50+
}
51+
});
52+
core.setOutput('node-version', installedVersion);
53+
4254
const registryUrl: string = core.getInput('registry-url');
4355
const alwaysAuth: string = core.getInput('always-auth');
4456
if (registryUrl) {

0 commit comments

Comments
 (0)