From 6b8a8e58a99393974fb89c81d8a698944388eb2e Mon Sep 17 00:00:00 2001 From: Thomas Boop <52323235+thboop@users.noreply.github.com> Date: Mon, 13 Apr 2020 13:25:54 -0400 Subject: [PATCH] Add docs and wrapper for "echo" command (#411) * Add docs and wrapper for "echo" command * Update parameter to enabled --- __tests__/core.test.ts | 10 ++++++++++ src/core.ts | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/__tests__/core.test.ts b/__tests__/core.test.ts index d10e059..2901065 100644 --- a/__tests__/core.test.ts +++ b/__tests__/core.test.ts @@ -239,6 +239,16 @@ describe('@actions/core', () => { process.env['RUNNER_DEBUG'] = current } }) + + it('setCommandEcho can enable echoing', () => { + core.setCommandEcho(true) + assertWriteCalls([`::echo::on${os.EOL}`]) + }) + + it('setCommandEcho can disable echoing', () => { + core.setCommandEcho(false) + assertWriteCalls([`::echo::off${os.EOL}`]) + }) }) // Assert that process.stdout.write calls called only with the given arguments. diff --git a/src/core.ts b/src/core.ts index 85fc547..0cf9f04 100644 --- a/src/core.ts +++ b/src/core.ts @@ -87,6 +87,15 @@ export function setOutput(name: string, value: any): void { issueCommand('set-output', {name}, value) } +/** + * Enables or disables the echoing of commands into stdout for the rest of the step. + * Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set. + * + */ +export function setCommandEcho(enabled: boolean): void { + issue('echo', enabled ? 'on' : 'off') +} + //----------------------------------------------------------------------- // Results //-----------------------------------------------------------------------