(
{
challengeFiles,
challengeType
}: { challengeFiles?: ChallengeFile[]; challengeType: number },
options: BuildOptions
)
| 264 | } |
| 265 | |
| 266 | async 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 | |
| 298 | function buildBackendChallenge({ url, challengeType }: BuildChallengeData) { |
| 299 | return { |
nothing calls this directly
no test coverage detected