Skip to content

Commit

Permalink
feat: add support for returning boolean if custom patterns are used
Browse files Browse the repository at this point in the history
  • Loading branch information
jackton1 committed Sep 25, 2022
1 parent 850e530 commit d5f1943
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
12 changes: 12 additions & 0 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
})
4 changes: 3 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
8 changes: 8 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,14 @@ export async function run(): Promise<void> {
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) {
Expand Down

0 comments on commit d5f1943

Please sign in to comment.