From 114d07bdd6f5fe6ea08aff50a67aa9763b9e7b51 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 --- __tests__/lib.test.ts | 5 +++++ src/core.ts | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/__tests__/lib.test.ts b/__tests__/lib.test.ts index 49f4206..ad8e083 100644 --- a/__tests__/lib.test.ts +++ b/__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/src/core.ts b/src/core.ts index 7e3d7e0..355045c 100644 --- a/src/core.ts +++ b/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 9f7b3b53ade9763f8980bbda2994c9e89b1b50c5 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 --- src/core.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core.ts b/src/core.ts index 355045c..7510566 100644 --- a/src/core.ts +++ b/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 3e793a6c0299b8ad517f8c1fc21aeaa77ba0b2a0 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 --- src/core.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core.ts b/src/core.ts index 7510566..ec98624 100644 --- a/src/core.ts +++ b/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) } //-----------------------------------------------------------------------