feat(learn): sync master and next-curriculum branches
This commit is contained in:
committed by
Mrugesh Mohapatra
parent
c648a595df
commit
4f1be63055
@ -8,15 +8,15 @@ class ChallengeTitles {
|
||||
`Expected a valid string for ${title}, but got a(n) ${typeof title}`
|
||||
);
|
||||
}
|
||||
const titleToCheck = title.replace(/\s+/g, '').toLowerCase();
|
||||
let titleToCheck = title.replace(/\s+/g, '').toLowerCase();
|
||||
if (titleToCheck.length === 0) {
|
||||
throw new Error('Expected a title length greater than 0');
|
||||
}
|
||||
const isProjectCurriculumChallenge = title.match(/^Part\s*\d+/);
|
||||
const titleToAdd = isProjectCurriculumChallenge
|
||||
? pathAndTitle
|
||||
: titleToCheck;
|
||||
const isKnown = this.knownTitles.includes(titleToAdd);
|
||||
// reassign titleToCheck if challenge is part of the project
|
||||
// based curriculum
|
||||
const isProjectCurriculumChallenge = title.match(/^Part\s*\d+$/);
|
||||
titleToCheck = isProjectCurriculumChallenge ? pathAndTitle : titleToCheck;
|
||||
const isKnown = this.knownTitles.includes(titleToCheck);
|
||||
if (isKnown) {
|
||||
throw new Error(`
|
||||
All current curriculum challenges must have a unique title.
|
||||
@ -24,7 +24,7 @@ class ChallengeTitles {
|
||||
The title ${title} (at ${pathAndTitle}) is already assigned
|
||||
`);
|
||||
}
|
||||
this.knownTitles = [...this.knownTitles, titleToAdd];
|
||||
this.knownTitles = [...this.knownTitles, titleToCheck];
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user