Skip to content

Commit

Permalink
add set-output command
Browse files Browse the repository at this point in the history
  • Loading branch information
vtbassmatt committed Jun 24, 2019
1 parent d8737aa commit 55c0e70
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/core/__tests__/lib.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions packages/core/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
//-----------------------------------------------------------------------
Expand Down

0 comments on commit 55c0e70

Please sign in to comment.