From 55c0e7020e28b33ccf4c24213b0a619482d2d2c4 Mon Sep 17 00:00:00 2001 From: Matt Cooper Date: Mon, 24 Jun 2019 16:14:47 -0400 Subject: [PATCH 1/3] add set-output command --- packages/core/__tests__/lib.test.ts | 5 +++++ packages/core/src/core.ts | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/packages/core/__tests__/lib.test.ts b/packages/core/__tests__/lib.test.ts index 49f42062..ad8e083d 100644 --- a/packages/core/__tests__/lib.test.ts +++ b/packages/core/__tests__/lib.test.ts @@ -114,6 +114,11 @@ describe('@actions/core', () => { expect(core.getInput('special chars_\'\t"\\')).toBe('\'\t"\\ repsonse') }) + it('setOutput produces the correct command', () => { + core.setOutput('some output', 'some value') + assertWriteCalls([`##[set-output name=some output;]some value${os.EOL}`]) + }) + it('setNeutral sets the correct exit code', () => { core.setFailed('Failure message') expect(process.exitCode).toBe(ExitCode.Failure) diff --git a/packages/core/src/core.ts b/packages/core/src/core.ts index 7e3d7e0d..355045cd 100644 --- a/packages/core/src/core.ts +++ b/packages/core/src/core.ts @@ -61,6 +61,16 @@ export function getInput(name: string, options?: InputOptions): string { return val.trim() } +/** + * Sets the value of an output. + * + * @param name name of the output to set + * @param value value to store + */ +export function setOutput(name: string, value: string): void { + issueCommand('set-output', {'name': name}, value) +} + //----------------------------------------------------------------------- // Results //----------------------------------------------------------------------- From 9b0b34561737aa0000761ed3ad1e5e497cdec0f7 Mon Sep 17 00:00:00 2001 From: Matt Cooper Date: Tue, 25 Jun 2019 07:11:28 -0400 Subject: [PATCH 2/3] npm run format --- packages/core/src/core.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/src/core.ts b/packages/core/src/core.ts index 355045cd..7510566c 100644 --- a/packages/core/src/core.ts +++ b/packages/core/src/core.ts @@ -68,7 +68,7 @@ export function getInput(name: string, options?: InputOptions): string { * @param value value to store */ export function setOutput(name: string, value: string): void { - issueCommand('set-output', {'name': name}, value) + issueCommand('set-output', {name: name}, value) } //----------------------------------------------------------------------- From b8a0fd6e7862ed0a69dba239f26d79894c7b29e4 Mon Sep 17 00:00:00 2001 From: Matt Cooper Date: Tue, 25 Jun 2019 07:19:19 -0400 Subject: [PATCH 3/3] object shorthand syntax ...is an abomination, but I don't make the rules =P --- packages/core/src/core.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/src/core.ts b/packages/core/src/core.ts index 7510566c..ec98624e 100644 --- a/packages/core/src/core.ts +++ b/packages/core/src/core.ts @@ -68,7 +68,7 @@ export function getInput(name: string, options?: InputOptions): string { * @param value value to store */ export function setOutput(name: string, value: string): void { - issueCommand('set-output', {name: name}, value) + issueCommand('set-output', {name}, value) } //-----------------------------------------------------------------------