Skip to content

Commit

Permalink
Prepend newline for set-output
Browse files Browse the repository at this point in the history
  • Loading branch information
ericsciple committed Apr 13, 2021
1 parent 8afb976 commit 4a45fd8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/core/__tests__/core.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,17 +159,20 @@ describe('@actions/core', () => {

it('setOutput produces the correct command', () => {
core.setOutput('some output', 'some value')
assertWriteCalls([`::set-output name=some output::some value${os.EOL}`])
assertWriteCalls([
os.EOL,
`::set-output name=some output::some value${os.EOL}`
])
})

it('setOutput handles bools', () => {
core.setOutput('some output', false)
assertWriteCalls([`::set-output name=some output::false${os.EOL}`])
assertWriteCalls([os.EOL, `::set-output name=some output::false${os.EOL}`])
})

it('setOutput handles numbers', () => {
core.setOutput('some output', 1.01)
assertWriteCalls([`::set-output name=some output::1.01${os.EOL}`])
assertWriteCalls([os.EOL, `::set-output name=some output::1.01${os.EOL}`])
})

it('setFailed sets the correct exit code and failure message', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export function getInput(name: string, options?: InputOptions): string {
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function setOutput(name: string, value: any): void {
process.stdout.write(os.EOL)
issueCommand('set-output', {name}, value)
}

Expand Down

0 comments on commit 4a45fd8

Please sign in to comment.