bugfix for glob exclude patterns (#100)
Signed-off-by: Brian DeHamer <[email protected]>
This commit is contained in:
@@ -296,6 +296,29 @@ describe('subjectFromInputs', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('when an excluding glob is supplied', () => {
|
||||||
|
it('returns the multiple subjects', async () => {
|
||||||
|
const inputs: SubjectInputs = {
|
||||||
|
...blankInputs,
|
||||||
|
subjectPath: `${path.join(dir, 'subject-*')},!${path.join(dir, 'subject-1')}`
|
||||||
|
}
|
||||||
|
|
||||||
|
const subjects = await subjectFromInputs(inputs)
|
||||||
|
|
||||||
|
expect(subjects).toBeDefined()
|
||||||
|
expect(subjects).toHaveLength(2)
|
||||||
|
|
||||||
|
expect(subjects).toContainEqual({
|
||||||
|
name: 'subject-0',
|
||||||
|
digest: { sha256: expectedDigest }
|
||||||
|
})
|
||||||
|
expect(subjects).toContainEqual({
|
||||||
|
name: 'subject-2',
|
||||||
|
digest: { sha256: expectedDigest }
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe('when a multi-line glob list is supplied', () => {
|
describe('when a multi-line glob list is supplied', () => {
|
||||||
it('returns the multiple subjects', async () => {
|
it('returns the multiple subjects', async () => {
|
||||||
const inputs: SubjectInputs = {
|
const inputs: SubjectInputs = {
|
||||||
|
|||||||
+2
-5
@@ -80356,14 +80356,11 @@ exports.subjectFromInputs = subjectFromInputs;
|
|||||||
// calculated and returned along with the subject's name.
|
// calculated and returned along with the subject's name.
|
||||||
const getSubjectFromPath = async (subjectPath, subjectName) => {
|
const getSubjectFromPath = async (subjectPath, subjectName) => {
|
||||||
const digestedSubjects = [];
|
const digestedSubjects = [];
|
||||||
const files = [];
|
|
||||||
// Parse the list of subject paths
|
// Parse the list of subject paths
|
||||||
const subjectPaths = parseList(subjectPath);
|
const subjectPaths = parseList(subjectPath).join('\n');
|
||||||
// Expand the globbed paths to a list of files
|
// Expand the globbed paths to a list of files
|
||||||
for (const subPath of subjectPaths) {
|
|
||||||
/* eslint-disable-next-line github/no-then */
|
/* eslint-disable-next-line github/no-then */
|
||||||
files.push(...(await glob.create(subPath).then(async (g) => g.glob())));
|
const files = await glob.create(subjectPaths).then(async (g) => g.glob());
|
||||||
}
|
|
||||||
if (files.length > MAX_SUBJECT_COUNT) {
|
if (files.length > MAX_SUBJECT_COUNT) {
|
||||||
throw new Error(`Too many subjects specified. The maximum number of subjects is ${MAX_SUBJECT_COUNT}.`);
|
throw new Error(`Too many subjects specified. The maximum number of subjects is ${MAX_SUBJECT_COUNT}.`);
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-5
@@ -56,16 +56,13 @@ const getSubjectFromPath = async (
|
|||||||
subjectName?: string
|
subjectName?: string
|
||||||
): Promise<Subject[]> => {
|
): Promise<Subject[]> => {
|
||||||
const digestedSubjects: Subject[] = []
|
const digestedSubjects: Subject[] = []
|
||||||
const files: string[] = []
|
|
||||||
|
|
||||||
// Parse the list of subject paths
|
// Parse the list of subject paths
|
||||||
const subjectPaths = parseList(subjectPath)
|
const subjectPaths = parseList(subjectPath).join('\n')
|
||||||
|
|
||||||
// Expand the globbed paths to a list of files
|
// Expand the globbed paths to a list of files
|
||||||
for (const subPath of subjectPaths) {
|
|
||||||
/* eslint-disable-next-line github/no-then */
|
/* eslint-disable-next-line github/no-then */
|
||||||
files.push(...(await glob.create(subPath).then(async g => g.glob())))
|
const files = await glob.create(subjectPaths).then(async g => g.glob())
|
||||||
}
|
|
||||||
|
|
||||||
if (files.length > MAX_SUBJECT_COUNT) {
|
if (files.length > MAX_SUBJECT_COUNT) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
|
|||||||
Reference in New Issue
Block a user