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

ensure subject globs match only files #54

Merged
merged 1 commit into from
May 6, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions __tests__/subject.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,19 @@ describe('subjectFromInputs', () => {
})
})

describe('when a file glob is supplied which also matches non-files', () => {
beforeEach(async () => {
process.env['INPUT_SUBJECT-PATH'] = `${dir}*`
})

it('returns the subjects (excluding non-files)', async () => {
const subjects = await subjectFromInputs()

expect(subjects).toBeDefined()
expect(subjects).toHaveLength(7)
})
})

describe('when a comma-separated list is supplied', () => {
beforeEach(async () => {
process.env['INPUT_SUBJECT-PATH'] =
Expand Down
4 changes: 4 additions & 0 deletions dist/index.js

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

5 changes: 5 additions & 0 deletions src/subject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ const getSubjectFromPath = async (
const files = await glob.create(subPath).then(async g => g.glob())

for (const file of files) {
// Skip anything that is NOT a file
if (!fs.statSync(file).isFile()) {
continue
}

const name = subjectName || path.parse(file).base
const digest = await digestFile(DIGEST_ALGORITHM, file)

Expand Down
Loading