Skip to content

Commit

Permalink
Merge pull request #625 from tj-actions/feat/add-warning-message-for-…
Browse files Browse the repository at this point in the history
…invalid-patterns
  • Loading branch information
jackton1 committed Jan 18, 2023
2 parents dc8e7c4 + 7dd123a commit 70ce922
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 12 deletions.
12 changes: 8 additions & 4 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions src/__tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,3 +378,19 @@ test('matched file patterns with braces are expanded', async () => {

expect(core.setOutput).toHaveBeenNthCalledWith(2, 'paths', EXPECTED_FILENAMES)
})

test('warnings are logged when files are not found', async () => {
mockedEnv({
...defaultEnv,
INPUT_FILES: 'src/__tests__/not-found.txt'
})

// @ts-ignore
core.warning = jest.fn()

await run()

expect(core.warning).toHaveBeenCalledWith(
'No paths found using the specified patterns'
)
})
16 changes: 9 additions & 7 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,23 +263,25 @@ export async function run(): Promise<void> {

const pathsOutput = paths.join(separator)

const hasCustomPatterns =
files !== '' ||
filesFromSourceFile !== '' ||
excludedFiles !== '' ||
excludedFilesFromSourceFile !== ''

if (pathsOutput) {
const pathsOutputFile = await tempfile('.txt')
await fs.writeFile(pathsOutputFile, pathsOutput, {flag: 'w'})

core.setOutput('paths-output-file', pathsOutputFile)
core.saveState('paths-output-file', pathsOutputFile)
core.info(`Successfully created paths-output-file: ${pathsOutputFile}`)
} else if (hasCustomPatterns) {
core.warning('No paths found using the specified patterns')
}

core.setOutput('paths', pathsOutput)
core.setOutput(
'has-custom-patterns',
files !== '' ||
filesFromSourceFile !== '' ||
excludedFiles !== '' ||
excludedFilesFromSourceFile !== ''
)
core.setOutput('has-custom-patterns', hasCustomPatterns)
}

if (!process.env.TESTING) {
Expand Down

0 comments on commit 70ce922

Please sign in to comment.