mirror of
https://github.com/crazy-max/ghaction-import-gpg.git
synced 2024-11-29 08:21:06 -05:00
Merge pull request #152 from crazy-max/setOutput
Remove setOutput workaround
This commit is contained in:
commit
111c56156b
5 changed files with 6 additions and 47 deletions
|
@ -1,35 +0,0 @@
|
||||||
import {beforeEach, describe, expect, it, jest} from '@jest/globals';
|
|
||||||
import * as os from 'os';
|
|
||||||
import * as context from '../src/context';
|
|
||||||
|
|
||||||
describe('setOutput', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
process.stdout.write = jest.fn() as typeof process.stdout.write;
|
|
||||||
});
|
|
||||||
|
|
||||||
// eslint-disable-next-line jest/expect-expect
|
|
||||||
it('setOutput produces the correct command', () => {
|
|
||||||
context.setOutput('some output', 'some value');
|
|
||||||
assertWriteCalls([`::set-output name=some output::some value${os.EOL}`]);
|
|
||||||
});
|
|
||||||
|
|
||||||
// eslint-disable-next-line jest/expect-expect
|
|
||||||
it('setOutput handles bools', () => {
|
|
||||||
context.setOutput('some output', false);
|
|
||||||
assertWriteCalls([`::set-output name=some output::false${os.EOL}`]);
|
|
||||||
});
|
|
||||||
|
|
||||||
// eslint-disable-next-line jest/expect-expect
|
|
||||||
it('setOutput handles numbers', () => {
|
|
||||||
context.setOutput('some output', 1.01);
|
|
||||||
assertWriteCalls([`::set-output name=some output::1.01${os.EOL}`]);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// Assert that process.stdout.write calls called only with the given arguments.
|
|
||||||
function assertWriteCalls(calls: string[]): void {
|
|
||||||
expect(process.stdout.write).toHaveBeenCalledTimes(calls.length);
|
|
||||||
for (let i = 0; i < calls.length; i++) {
|
|
||||||
expect(process.stdout.write).toHaveBeenNthCalledWith(i + 1, calls[i]);
|
|
||||||
}
|
|
||||||
}
|
|
2
dist/index.js
generated
vendored
2
dist/index.js
generated
vendored
File diff suppressed because one or more lines are too long
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
|
@ -1,5 +1,4 @@
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import {issueCommand} from '@actions/core/lib/command';
|
|
||||||
|
|
||||||
export interface Inputs {
|
export interface Inputs {
|
||||||
gpgPrivateKey: string;
|
gpgPrivateKey: string;
|
||||||
|
@ -30,8 +29,3 @@ export async function getInputs(): Promise<Inputs> {
|
||||||
fingerprint: core.getInput('fingerprint')
|
fingerprint: core.getInput('fingerprint')
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Temp fix https://github.com/actions/toolkit/issues/777
|
|
||||||
export function setOutput(name: string, value: any): void {
|
|
||||||
issueCommand('set-output', {name}, value);
|
|
||||||
}
|
|
||||||
|
|
|
@ -83,13 +83,13 @@ async function run(): Promise<void> {
|
||||||
|
|
||||||
await core.group(`Setting outputs`, async () => {
|
await core.group(`Setting outputs`, async () => {
|
||||||
core.info(`fingerprint=${fingerprint}`);
|
core.info(`fingerprint=${fingerprint}`);
|
||||||
context.setOutput('fingerprint', fingerprint);
|
core.setOutput('fingerprint', fingerprint);
|
||||||
core.info(`keyid=${privateKey.keyID}`);
|
core.info(`keyid=${privateKey.keyID}`);
|
||||||
context.setOutput('keyid', privateKey.keyID);
|
core.setOutput('keyid', privateKey.keyID);
|
||||||
core.info(`name=${privateKey.name}`);
|
core.info(`name=${privateKey.name}`);
|
||||||
context.setOutput('name', privateKey.name);
|
core.setOutput('name', privateKey.name);
|
||||||
core.info(`email=${privateKey.email}`);
|
core.info(`email=${privateKey.email}`);
|
||||||
context.setOutput('email', privateKey.email);
|
core.setOutput('email', privateKey.email);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (inputs.gitUserSigningkey) {
|
if (inputs.gitUserSigningkey) {
|
||||||
|
|
Loading…
Reference in a new issue