Skip to content

Commit c56af95

Browse files
authored
Merge pull request #704 from crazy-max/setOutput
Remove workaround for setOutput
2 parents f97d6e2 + 75aaa63 commit c56af95

File tree

5 files changed

+7
-48
lines changed

5 files changed

+7
-48
lines changed

__tests__/context.test.ts

-33
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {beforeEach, describe, expect, it, jest, test} from '@jest/globals';
22
import * as fs from 'fs';
3-
import * as os from 'os';
43
import * as path from 'path';
54

65
import * as context from '../src/context';
@@ -690,30 +689,6 @@ describe('asyncForEach', () => {
690689
});
691690
});
692691

693-
describe('setOutput', () => {
694-
beforeEach(() => {
695-
process.stdout.write = jest.fn() as typeof process.stdout.write;
696-
});
697-
698-
// eslint-disable-next-line jest/expect-expect
699-
it('setOutput produces the correct command', () => {
700-
context.setOutput('some output', 'some value');
701-
assertWriteCalls([`::set-output name=some output::some value${os.EOL}`]);
702-
});
703-
704-
// eslint-disable-next-line jest/expect-expect
705-
it('setOutput handles bools', () => {
706-
context.setOutput('some output', false);
707-
assertWriteCalls([`::set-output name=some output::false${os.EOL}`]);
708-
});
709-
710-
// eslint-disable-next-line jest/expect-expect
711-
it('setOutput handles numbers', () => {
712-
context.setOutput('some output', 1.01);
713-
assertWriteCalls([`::set-output name=some output::1.01${os.EOL}`]);
714-
});
715-
});
716-
717692
// See: https://github.com/actions/toolkit/blob/a1b068ec31a042ff1e10a522d8fdf0b8869d53ca/packages/core/src/core.ts#L89
718693
function getInputName(name: string): string {
719694
return `INPUT_${name.replace(/ /g, '_').toUpperCase()}`;
@@ -722,11 +697,3 @@ function getInputName(name: string): string {
722697
function setInput(name: string, value: string): void {
723698
process.env[getInputName(name)] = value;
724699
}
725-
726-
// Assert that process.stdout.write calls called only with the given arguments.
727-
function assertWriteCalls(calls: string[]): void {
728-
expect(process.stdout.write).toHaveBeenCalledTimes(calls.length);
729-
for (let i = 0; i < calls.length; i++) {
730-
expect(process.stdout.write).toHaveBeenNthCalledWith(i + 1, calls[i]);
731-
}
732-
}

dist/index.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/context.ts

+2-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
import {parse} from 'csv-parse/sync';
21
import * as fs from 'fs';
32
import * as os from 'os';
43
import * as path from 'path';
54
import * as tmp from 'tmp';
6-
5+
import * as buildx from './buildx';
76
import * as core from '@actions/core';
8-
import {issueCommand} from '@actions/core/lib/command';
97
import * as github from '@actions/github';
10-
11-
import * as buildx from './buildx';
8+
import {parse} from 'csv-parse/sync';
129
import * as handlebars from 'handlebars';
1310

1411
let _defaultContext, _tmpDir: string;
@@ -248,8 +245,3 @@ export const asyncForEach = async (array, callback) => {
248245
await callback(array[index], index, array);
249246
}
250247
};
251-
252-
// FIXME: Temp fix https://github.com/actions/toolkit/issues/777
253-
export function setOutput(name: string, value: unknown): void {
254-
issueCommand('set-output', {name}, value);
255-
}

src/main.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,19 @@ async function run(): Promise<void> {
6060
if (imageID) {
6161
await core.group(`ImageID`, async () => {
6262
core.info(imageID);
63-
context.setOutput('imageid', imageID);
63+
core.setOutput('imageid', imageID);
6464
});
6565
}
6666
if (digest) {
6767
await core.group(`Digest`, async () => {
6868
core.info(digest);
69-
context.setOutput('digest', digest);
69+
core.setOutput('digest', digest);
7070
});
7171
}
7272
if (metadata) {
7373
await core.group(`Metadata`, async () => {
7474
core.info(metadata);
75-
context.setOutput('metadata', metadata);
75+
core.setOutput('metadata', metadata);
7676
});
7777
}
7878
} catch (error) {

0 commit comments

Comments
 (0)