From aab7cc882a63a6e74f0d36e92552d03d190d4e7e Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Tue, 12 Jul 2022 10:30:30 +0200 Subject: [PATCH 1/6] 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/6] 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/6] 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/6] 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/6] 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'; From 2fddd8803e2f5c9604345a0b591c3020ee971a93 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Wed, 13 Jul 2022 16:20:39 +0200 Subject: [PATCH 6/6] fixing pnpm output issue (#545) --- dist/cache-save/index.js | 4 ++-- dist/setup/index.js | 4 ++-- src/cache-utils.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dist/cache-save/index.js b/dist/cache-save/index.js index ccd3a5a3a..a79693b2b 100644 --- a/dist/cache-save/index.js +++ b/dist/cache-save/index.js @@ -59931,7 +59931,7 @@ exports.supportedPackageManagers = { }, pnpm: { lockFilePatterns: ['pnpm-lock.yaml'], - getCacheFolderCommand: 'pnpm store path' + getCacheFolderCommand: 'pnpm store path --silent' }, yarn1: { lockFilePatterns: ['yarn.lock'], @@ -59986,7 +59986,7 @@ exports.getCacheDirectoryPath = (packageManagerInfo, packageManager) => __awaite throw new Error(`Could not get cache folder path for ${packageManager}`); } core.debug(`${packageManager} path is ${stdOut}`); - return stdOut; + return stdOut.trim(); }); function isGhes() { const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); diff --git a/dist/setup/index.js b/dist/setup/index.js index 801cf3308..28d5dc8fd 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -71277,7 +71277,7 @@ exports.supportedPackageManagers = { }, pnpm: { lockFilePatterns: ['pnpm-lock.yaml'], - getCacheFolderCommand: 'pnpm store path' + getCacheFolderCommand: 'pnpm store path --silent' }, yarn1: { lockFilePatterns: ['yarn.lock'], @@ -71332,7 +71332,7 @@ exports.getCacheDirectoryPath = (packageManagerInfo, packageManager) => __awaite throw new Error(`Could not get cache folder path for ${packageManager}`); } core.debug(`${packageManager} path is ${stdOut}`); - return stdOut; + return stdOut.trim(); }); function isGhes() { const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); diff --git a/src/cache-utils.ts b/src/cache-utils.ts index 4db730eb1..ccd4e9876 100644 --- a/src/cache-utils.ts +++ b/src/cache-utils.ts @@ -18,7 +18,7 @@ export const supportedPackageManagers: SupportedPackageManagers = { }, pnpm: { lockFilePatterns: ['pnpm-lock.yaml'], - getCacheFolderCommand: 'pnpm store path' + getCacheFolderCommand: 'pnpm store path --silent' }, yarn1: { lockFilePatterns: ['yarn.lock'], @@ -94,7 +94,7 @@ export const getCacheDirectoryPath = async ( core.debug(`${packageManager} path is ${stdOut}`); - return stdOut; + return stdOut.trim(); }; export function isGhes(): boolean {