Skip to content

Commit d442d85

Browse files
authored
ensure subject globs match only files (#54)
Signed-off-by: Brian DeHamer <[email protected]>
1 parent c58d52c commit d442d85

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

__tests__/subject.test.ts

+13
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,19 @@ describe('subjectFromInputs', () => {
203203
})
204204
})
205205

206+
describe('when a file glob is supplied which also matches non-files', () => {
207+
beforeEach(async () => {
208+
process.env['INPUT_SUBJECT-PATH'] = `${dir}*`
209+
})
210+
211+
it('returns the subjects (excluding non-files)', async () => {
212+
const subjects = await subjectFromInputs()
213+
214+
expect(subjects).toBeDefined()
215+
expect(subjects).toHaveLength(7)
216+
})
217+
})
218+
206219
describe('when a comma-separated list is supplied', () => {
207220
beforeEach(async () => {
208221
process.env['INPUT_SUBJECT-PATH'] =

dist/index.js

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/subject.ts

+5
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ const getSubjectFromPath = async (
5656
const files = await glob.create(subPath).then(async g => g.glob())
5757

5858
for (const file of files) {
59+
// Skip anything that is NOT a file
60+
if (!fs.statSync(file).isFile()) {
61+
continue
62+
}
63+
5964
const name = subjectName || path.parse(file).base
6065
const digest = await digestFile(DIGEST_ALGORITHM, file)
6166

0 commit comments

Comments
 (0)