Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error node version output #540

Merged
merged 5 commits into from Jul 12, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions dist/setup/index.js
Expand Up @@ -71846,8 +71846,13 @@ function run() {
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);
try {
const { stdout: installedVersion } = yield exec.getExecOutput('node', ['--version'], { ignoreReturnCode: true, silent: true });
core.setOutput('node-version', installedVersion.trim());
}
catch (err) {
core.setOutput('node-version', '');
}
const registryUrl = core.getInput('registry-url');
const alwaysAuth = core.getInput('always-auth');
if (registryUrl) {
Expand Down
17 changes: 11 additions & 6 deletions src/main.ts
Expand Up @@ -2,6 +2,7 @@ import * as core from '@actions/core';
import * as exec from '@actions/exec';
import * as installer from './installer';
import fs from 'fs';
import * as child_process from 'child_process';
dmitry-shibanov marked this conversation as resolved.
Show resolved Hide resolved
import * as auth from './authutil';
import * as path from 'path';
import {restoreCache} from './cache-restore';
Expand Down Expand Up @@ -41,12 +42,16 @@ export async function run() {
}

// Output version of node is being used
const {stdout: installedVersion} = await exec.getExecOutput(
'node',
['--version'],
{ignoreReturnCode: true}
);
core.setOutput('node-version', installedVersion);
try {
const {stdout: installedVersion} = await exec.getExecOutput(
'node',
['--version'],
{ignoreReturnCode: true, silent: true}
);
core.setOutput('node-version', installedVersion.trim());
} catch (err) {
core.setOutput('node-version', '');
}

const registryUrl: string = core.getInput('registry-url');
const alwaysAuth: string = core.getInput('always-auth');
Expand Down