ensure subject globs match only files (#54)
Signed-off-by: Brian DeHamer <[email protected]>
This commit is contained in:
@@ -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', () => {
|
describe('when a comma-separated list is supplied', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
process.env['INPUT_SUBJECT-PATH'] =
|
process.env['INPUT_SUBJECT-PATH'] =
|
||||||
|
|||||||
+4
@@ -79897,6 +79897,10 @@ const getSubjectFromPath = async (subjectPath, subjectName) => {
|
|||||||
/* eslint-disable-next-line github/no-then */
|
/* eslint-disable-next-line github/no-then */
|
||||||
const files = await glob.create(subPath).then(async (g) => g.glob());
|
const files = await glob.create(subPath).then(async (g) => g.glob());
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
|
// Skip anything that is NOT a file
|
||||||
|
if (!fs_1.default.statSync(file).isFile()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
const name = subjectName || path_1.default.parse(file).base;
|
const name = subjectName || path_1.default.parse(file).base;
|
||||||
const digest = await digestFile(DIGEST_ALGORITHM, file);
|
const digest = await digestFile(DIGEST_ALGORITHM, file);
|
||||||
subjects.push({ name, digest: { [DIGEST_ALGORITHM]: digest } });
|
subjects.push({ name, digest: { [DIGEST_ALGORITHM]: digest } });
|
||||||
|
|||||||
@@ -56,6 +56,11 @@ const getSubjectFromPath = async (
|
|||||||
const files = await glob.create(subPath).then(async g => g.glob())
|
const files = await glob.create(subPath).then(async g => g.glob())
|
||||||
|
|
||||||
for (const file of files) {
|
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 name = subjectName || path.parse(file).base
|
||||||
const digest = await digestFile(DIGEST_ALGORITHM, file)
|
const digest = await digestFile(DIGEST_ALGORITHM, file)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user