MCPcopy Create free account
hub / github.com/freeCodeCamp/freeCodeCamp / buildJSChallenge

Function buildJSChallenge

packages/challenge-builder/src/build.ts:266–296  ·  view source on GitHub ↗
(
  {
    challengeFiles,
    challengeType
  }: { challengeFiles?: ChallengeFile[]; challengeType: number },
  options: BuildOptions
)

Source from the content-addressed store, hash-verified

264}
265
266async function buildJSChallenge(
267 {
268 challengeFiles,
269 challengeType
270 }: { challengeFiles?: ChallengeFile[]; challengeType: number },
271 options: BuildOptions
272): Promise<BuildResult> {
273 if (!challengeFiles) throw Error('No challenge files provided');
274 const pipeLine = composeFunctions(
275 ...(getTransformers(options) as unknown as ApplyFunctionProps[])
276 );
277
278 await configureTSCompiler(challengeFiles);
279 const sourceFiles = challengeFiles.filter(file => !isTSConfig(file));
280 const finalFiles = await Promise.all(sourceFiles?.map(pipeLine));
281 const error = finalFiles.find(({ error }) => error)?.error;
282
283 const toBuild = error ? [] : finalFiles;
284
285 return {
286 challengeType,
287 build: toBuild
288 .reduce(
289 (body, challengeFile) => [...body, challengeFile.contents],
290 [] as string[]
291 )
292 .join('\n'),
293 sources: buildSourceMap(finalFiles),
294 error
295 };
296}
297
298function buildBackendChallenge({ url, challengeType }: BuildChallengeData) {
299 return {

Callers

nothing calls this directly

Calls 5

getTransformersFunction · 0.90
composeFunctionsFunction · 0.85
configureTSCompilerFunction · 0.85
isTSConfigFunction · 0.85
buildSourceMapFunction · 0.85

Tested by

no test coverage detected