Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add warning message for invalid patterns #625

Merged
merged 5 commits into from
Jan 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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