Repository: freeCodeCamp/freeCodeCamp
File: curriculum/get-challenges.js (JavaScript)

Code before:

  await assertHasEnglishSource(filePath, lang, englishPath);
  const challenge = isCert
    ? await parseCert(englishPath)
    : await createChallenge(filePath, meta);

  // this builds the entire block, even if we only want one challenge, which is
  // inefficient, but finding the next challenge without building the whole
  // block is fiddly.
  challengeBlock.challenges = [...challengeBlock.challenges, challenge];
}

// This is a slightly weird abstraction, but it lets us define helper functions
// without passing around a ton of arguments.
function generateChallengeCreator(lang, englishPath, i18nPath) {
  function addMetaToChallenge(challenge, meta) {
    function addChapterAndModuleToChallenge(challenge) {
      if (chapterBasedSuperBlocks.includes(challenge.superBlock)) {
        const chapter = getChapterFromBlock(
          challenge.block,
          fullStackSuperBlockStructure
        );

        if (!meta.isUpcomingChange && chapter.comingSoon) {
          throw Error(
            `The '${chapter.dashedName}' chapter is 'comingSoon', but it's '${meta.dashedName}' block is not hidden. Set its 'isUpcomingChange' set to 'true' in the 'meta.json' for the block to hide it.`
          );
        }

        challenge.chapter = chapter.dashedName;

        const module = getModuleFromBlock(
          challenge.block,
          fullStackSuperBlockStructure
        );

        if (!meta.isUpcomingChange && module.comingSoon) {
          throw Error(
            `The '${chapter.dashedName}' module is 'comingSoon', but it's '${meta.dashedName}' block is not hidden. Set its 'isUpcomingChange' set to 'true' in the 'meta.json' for the block to hide it.`
          );
        }

        challenge.module = module.dashedName;
      }
    }
    const challengeOrder = findIndex(
      meta.challengeOrder,
      ({ id }) => id === challenge.id
    );

    const isLastChallengeInBlock =

Review comment (suggestion):
```suggestion
            `The '${chapter.dashedName}' chapter is 'comingSoon', but its '${meta.dashedName}' block is not hidden. Set 'isUpcomingChange' to 'true' in the 'meta.json' for the block to hide it.`
```

Code after:

  await assertHasEnglishSource(filePath, lang, englishPath);
  const challenge = isCert
    ? await parseCert(englishPath)
    : await createChallenge(filePath, meta);

  // this builds the entire block, even if we only want one challenge, which is
  // inefficient, but finding the next challenge without building the whole
  // block is fiddly.
  challengeBlock.challenges = [...challengeBlock.challenges, challenge];
}

// This is a slightly weird abstraction, but it lets us define helper functions
// without passing around a ton of arguments.
function generateChallengeCreator(lang, englishPath, i18nPath) {
  function addMetaToChallenge(challenge, meta) {
    function addChapterAndModuleToChallenge(challenge) {
      if (chapterBasedSuperBlocks.includes(challenge.superBlock)) {
        const chapter = getChapterFromBlock(
          challenge.block,
          fullStackSuperBlockStructure
        );

        if (!meta.isUpcomingChange && chapter.comingSoon) {
          throw Error(
            `The '${chapter.dashedName}' chapter is 'comingSoon', but its '${meta.dashedName}' block is not hidden. Set 'isUpcomingChange' to 'true' in the 'meta.json' for the block to hide it.`
          );
        }

        challenge.chapter = chapter.dashedName;

        const module = getModuleFromBlock(
          challenge.block,
          fullStackSuperBlockStructure
        );

        if (!meta.isUpcomingChange && module.comingSoon) {
          throw Error(
            `The '${chapter.dashedName}' module is 'comingSoon', but its '${meta.dashedName}' block is not hidden. Set 'isUpcomingChange' to 'true' in the 'meta.json' for the block to hide it.`
          );
        }

        challenge.module = module.dashedName;
      }
    }
    const challengeOrder = findIndex(
      meta.challengeOrder,
      ({ id }) => id === challenge.id
    );

    const isLastChallengeInBlock =