From d5f194389a5b3a1d8df06df0edcd1fc2b088d055 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 24 Sep 2022 18:20:14 -0600 Subject: [PATCH] feat: add support for returning boolean if custom patterns are used --- __tests__/main.test.ts | 12 ++++++++++++ action.yml | 4 +++- src/main.ts | 8 ++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts index 897752e94..49af2b536 100644 --- a/__tests__/main.test.ts +++ b/__tests__/main.test.ts @@ -139,6 +139,17 @@ test('returns the paths of the filtered files (input source files)', async () => expect(core.setOutput).toHaveBeenNthCalledWith(1, 'paths', EXPECTED_FILENAMES) }) +test('returns true when no custom patterns are used', async () => { + mockedEnv(defaultEnv) + + // @ts-ignore + core.setOutput = jest.fn() + + await run() + + expect(core.setOutput).toHaveBeenNthCalledWith(3, 'has-custom-patterns', false) +}) + test('returns the paths of the filtered files in the paths-output-file', async () => { mockedEnv({ ...defaultEnv, @@ -173,4 +184,5 @@ test('returns the paths of the filtered files in the paths-output-file', async ( 'paths-output-file', pathsOutputFile ) + expect(core.setOutput).toHaveBeenNthCalledWith(3, 'has-custom-patterns', true) }) diff --git a/action.yml b/action.yml index e8d225f5a..4b700a6bd 100644 --- a/action.yml +++ b/action.yml @@ -73,7 +73,9 @@ outputs: paths: description: "List of filtered paths using the specified patterns and separator" paths-output-file: - description: "List of filtered paths using the specified patterns and separator stored in a tempfile" + description: "List of filtered paths using the specified patterns and separator stored in a temporary file" + has-custom-patterns: + description: "Indicates whether custom patterns were used" runs: using: 'node12' diff --git a/src/main.ts b/src/main.ts index a1ac984d9..646bb1ee8 100644 --- a/src/main.ts +++ b/src/main.ts @@ -196,6 +196,14 @@ export async function run(): Promise { core.saveState('paths-output-file', pathsOutputFile) core.info(`Successfully created paths-output-file: ${pathsOutputFile}`) } + + core.setOutput( + 'has-custom-patterns', + files !== '' || + filesFromSourceFile !== '' || + excludedFiles !== '' || + excludedFilesFromSourceFile !== '' + ) } if (!process.env.TESTING) {