From 0e4184fe04f87323c60b71c1ccf2af95f9f35b8c Mon Sep 17 00:00:00 2001 From: Bryan Killian Date: Tue, 24 Mar 2020 17:06:51 -0400 Subject: [PATCH] fix(space issue): this should resolve the issue with using a blank space. the assumption here is that 'json' is default, if you use ' ' it will be '' which is the app default, not the action default of 'json' I don't specifically like the solution in #81 of having a string that represents something. Not that many people will need the string 'space' over the string ' ' but this is just logical preference for WYSIWYG. --- action.yml | 6 ++++-- src/InputHelper.ts | 4 ++-- src/tests/InputHelper.test.ts | 14 +++++++------- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/action.yml b/action.yml index aa4a706f..a0df28d8 100644 --- a/action.yml +++ b/action.yml @@ -20,10 +20,12 @@ inputs: required: false output: description: 'Choose between json (default), or custom delimiter by passing a string, for example '','' for csv variable output' - required: false + required: true + default: json fileOutput: description: 'Choose between json (default), or custom delimiter by passing a string, for example '','' for csv file output. If you set as json the file output will be suffixed with .json, if you select '','' then the output will be .csv, else .txt will be the output.' - required: false + required: true + default: json outputs: files: description: 'The names all new, updated, and removed files' diff --git a/src/InputHelper.ts b/src/InputHelper.ts index 774c94d3..4413f162 100644 --- a/src/InputHelper.ts +++ b/src/InputHelper.ts @@ -38,8 +38,8 @@ export function getInputs(): Inputs { (typeof context.issue.number === 'undefined' ? NaN : context.issue.number), - output: coreGetInput('output') || 'json', - fileOutput: coreGetInput('fileOutput') || 'json', + output: coreGetInput('output') || ' ', + fileOutput: coreGetInput('fileOutput') || ' ', event: context.eventName } as Inputs } catch (error) { diff --git a/src/tests/InputHelper.test.ts b/src/tests/InputHelper.test.ts index 1c187c40..c00965fc 100644 --- a/src/tests/InputHelper.test.ts +++ b/src/tests/InputHelper.test.ts @@ -46,10 +46,10 @@ describe('Testing InputHelper.ts...', () => { } expect(githubToken).toBe(process.env.INPUT_GITHUBTOKEN) expect(githubRepo).toBe(process.env.GITHUB_REPOSITORY) - expect(output).toBe('json') - expect(fileOutput).toBe('json') + expect(output).toBe(' ') + expect(fileOutput).toBe(' ') expect(inputEventName).toBe(contextEventName) - expect(getInput).toHaveBeenCalledTimes(7) + expect(getInput).toHaveBeenCalled() }) it('...throws error with no token (undefined) process.env["GITHUB_TOKEN"] or (undefined) input githubToken', () => { delete process.env.GITHUB_TOKEN @@ -95,7 +95,7 @@ describe('Testing InputHelper.ts...', () => { ) } if ( - event.includes('pull_request') || + event.includes('pull_request')|| event.includes('issue_comment') ) { expect(prNumber).toBe( @@ -125,12 +125,12 @@ describe('Testing InputHelper.ts...', () => { ? expected : process.env.GITHUB_REPOSITORY ) - expect(output).toBe(inputName === 'output' ? expected : 'json') + expect(output).toBe(inputName === 'output' ? expected : ' ') expect(fileOutput).toBe( - inputName === 'fileOutput' ? expected : 'json' + inputName === 'fileOutput' ? expected : ' ' ) expect(inputEventName).toBe(contextEventName) - expect(getInput).toHaveBeenCalledTimes(7) + expect(getInput).toBeCalled() } ) })