From aab7cc882a63a6e74f0d36e92552d03d190d4e7e Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Tue, 12 Jul 2022 10:30:30 +0200 Subject: [PATCH 1/5] add silent --- dist/setup/index.js | 2 +- src/main.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 1b41467df..679421ccd 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -71846,7 +71846,7 @@ 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 }); + const { stdout: installedVersion } = yield exec.getExecOutput('node', ['--version'], { ignoreReturnCode: true, silent: false }); core.setOutput('node-version', installedVersion); const registryUrl = core.getInput('registry-url'); const alwaysAuth = core.getInput('always-auth'); diff --git a/src/main.ts b/src/main.ts index 5cfba617d..c17e8ae4d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -44,7 +44,7 @@ export async function run() { const {stdout: installedVersion} = await exec.getExecOutput( 'node', ['--version'], - {ignoreReturnCode: true} + {ignoreReturnCode: true, silent: false} ); core.setOutput('node-version', installedVersion); From 48de4c13f6f686eebe0d350838793fffd4421b26 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Tue, 12 Jul 2022 10:36:10 +0200 Subject: [PATCH 2/5] change to streams --- dist/setup/index.js | 11 ++++++++++- src/main.ts | 15 ++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 679421ccd..31aa5cc81 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -71846,7 +71846,16 @@ 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, silent: false }); + let installedVersion = ''; + const result = yield exec.exec('node', ['--version'], { + ignoreReturnCode: true, + silent: false, + listeners: { + stdout: data => { + installedVersion = data.toString(); + } + } + }); core.setOutput('node-version', installedVersion); const registryUrl = core.getInput('registry-url'); const alwaysAuth = core.getInput('always-auth'); diff --git a/src/main.ts b/src/main.ts index c17e8ae4d..88f99e016 100644 --- a/src/main.ts +++ b/src/main.ts @@ -41,11 +41,16 @@ export async function run() { } // Output version of node is being used - const {stdout: installedVersion} = await exec.getExecOutput( - 'node', - ['--version'], - {ignoreReturnCode: true, silent: false} - ); + let installedVersion = ''; + const result = await exec.exec('node', ['--version'], { + ignoreReturnCode: true, + silent: false, + listeners: { + stdout: data => { + installedVersion = data.toString(); + } + } + }); core.setOutput('node-version', installedVersion); const registryUrl: string = core.getInput('registry-url'); From 28ad38fe0624edc69ffde19aa0a6b8be0573641f Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Tue, 12 Jul 2022 10:45:50 +0200 Subject: [PATCH 3/5] add try catch --- dist/setup/index.js | 18 +++++++----------- src/main.ts | 21 ++++++++++----------- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 31aa5cc81..f203ff6a6 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -71846,17 +71846,13 @@ function run() { yield installer.getNode(version, stable, checkLatest, auth, arch); } // Output version of node is being used - let installedVersion = ''; - const result = yield exec.exec('node', ['--version'], { - ignoreReturnCode: true, - silent: false, - listeners: { - stdout: data => { - installedVersion = data.toString(); - } - } - }); - core.setOutput('node-version', installedVersion); + try { + const { stdout: installedVersion } = yield exec.getExecOutput('node', ['--version'], { ignoreReturnCode: true, silent: false }); + core.setOutput('node-version', installedVersion); + } + catch (err) { + core.setOutput('node-version', ''); + } const registryUrl = core.getInput('registry-url'); const alwaysAuth = core.getInput('always-auth'); if (registryUrl) { diff --git a/src/main.ts b/src/main.ts index 88f99e016..57f19229c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -41,17 +41,16 @@ export async function run() { } // Output version of node is being used - let installedVersion = ''; - const result = await exec.exec('node', ['--version'], { - ignoreReturnCode: true, - silent: false, - listeners: { - stdout: data => { - installedVersion = data.toString(); - } - } - }); - core.setOutput('node-version', installedVersion); + try { + const {stdout: installedVersion} = await exec.getExecOutput( + 'node', + ['--version'], + {ignoreReturnCode: true, silent: false} + ); + core.setOutput('node-version', installedVersion); + } catch (err) { + core.setOutput('node-version', ''); + } const registryUrl: string = core.getInput('registry-url'); const alwaysAuth: string = core.getInput('always-auth'); From 072a2e3b100f5d9394c602616700b044ce5e72f8 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Tue, 12 Jul 2022 14:19:55 +0200 Subject: [PATCH 4/5] add trim and silent true --- dist/setup/index.js | 4 ++-- src/main.ts | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index f203ff6a6..801cf3308 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -71847,8 +71847,8 @@ function run() { } // Output version of node is being used try { - const { stdout: installedVersion } = yield exec.getExecOutput('node', ['--version'], { ignoreReturnCode: true, silent: false }); - core.setOutput('node-version', installedVersion); + const { stdout: installedVersion } = yield exec.getExecOutput('node', ['--version'], { ignoreReturnCode: true, silent: true }); + core.setOutput('node-version', installedVersion.trim()); } catch (err) { core.setOutput('node-version', ''); diff --git a/src/main.ts b/src/main.ts index 57f19229c..21f9b33b4 100644 --- a/src/main.ts +++ b/src/main.ts @@ -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'; import * as auth from './authutil'; import * as path from 'path'; import {restoreCache} from './cache-restore'; @@ -45,9 +46,9 @@ export async function run() { const {stdout: installedVersion} = await exec.getExecOutput( 'node', ['--version'], - {ignoreReturnCode: true, silent: false} + {ignoreReturnCode: true, silent: true} ); - core.setOutput('node-version', installedVersion); + core.setOutput('node-version', installedVersion.trim()); } catch (err) { core.setOutput('node-version', ''); } From 3d11add77113802f5dc907ae13379fa7ffdcd839 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Tue, 12 Jul 2022 14:44:36 +0200 Subject: [PATCH 5/5] remove unused import --- src/main.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index 21f9b33b4..ac7e51f5c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -2,7 +2,6 @@ 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'; import * as auth from './authutil'; import * as path from 'path'; import {restoreCache} from './cache-restore';