fix(client): DRY out challenge sourcing
Also handles file changes the same way as the original sourcing.
This commit is contained in:
committed by
Mrugesh Mohapatra
parent
597ceba27f
commit
5bc3e15e3a
@ -41,9 +41,8 @@ exports.sourceNodes = function sourceChallengesSourceNodes(
|
||||
File changed at ${filePath}, replacing challengeNode id ${challenge.id}
|
||||
`
|
||||
);
|
||||
return createChallengeNode(challenge, reporter);
|
||||
createVisibleChallenge(challenge);
|
||||
})
|
||||
.then(createNode)
|
||||
.catch(e =>
|
||||
reporter.error(`fcc-replace-challenge
|
||||
|
||||
@ -58,12 +57,7 @@ File changed at ${filePath}, replacing challengeNode id ${challenge.id}
|
||||
return source()
|
||||
.then(challenges => Promise.all(challenges))
|
||||
.then(challenges =>
|
||||
challenges
|
||||
.filter(
|
||||
challenge => challenge.superBlock.toLowerCase() !== 'certificates'
|
||||
)
|
||||
.map(challenge => createChallengeNode(challenge, reporter))
|
||||
.map(node => createNode(node))
|
||||
challenges.map(challenge => createVisibleChallenge(challenge))
|
||||
)
|
||||
.catch(e =>
|
||||
reporter.panic(`fcc-source-challenges
|
||||
@ -74,6 +68,11 @@ File changed at ${filePath}, replacing challengeNode id ${challenge.id}
|
||||
);
|
||||
}
|
||||
|
||||
function createVisibleChallenge(challenge) {
|
||||
if (challenge.superBlock.toLowerCase() === 'certificates') return;
|
||||
createNode(createChallengeNode(challenge, reporter));
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
watcher.on('ready', () => sourceAndCreateNodes().then(resolve, reject));
|
||||
});
|
||||
|
Reference in New Issue
Block a user