Skip to content

Commit 3504247

Browse files
feat: remove 'original' and __file (freeCodeCamp#59446)
1 parent d91f57b commit 3504247

File tree

10 files changed

+5
-25
lines changed

10 files changed

+5
-25
lines changed

client/src/templates/Challenges/redux/execute-challenge-saga.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,7 @@ function* updatePython(challengeData) {
341341
interruptCodeExecution();
342342
const code = {
343343
contents: buildData.sources.index,
344-
editableContents: buildData.sources.editableContents,
345-
original: buildData.sources.original
344+
editableContents: buildData.sources.editableContents
346345
};
347346

348347
runPythonCode(code);

client/src/templates/Challenges/utils/build.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,22 +74,18 @@ const applyFunction =
7474
const composeFunctions = (...fns: ApplyFunctionProps[]) =>
7575
fns.map(applyFunction).reduce((f, g) => x => f(x).then(g));
7676

77-
// TODO: split this into at least two functions. One to create 'original' i.e.
78-
// the source and another to create the contents.
7977
function buildSourceMap(challengeFiles: ChallengeFile[]): Source | undefined {
8078
// TODO: rename sources.index to sources.contents.
8179
const source: Source | undefined = challengeFiles?.reduce(
8280
(sources, challengeFile) => {
8381
sources.index += challengeFile.source || '';
8482
sources.contents = sources.index;
85-
sources.original[challengeFile.history[0]] = challengeFile.source ?? null;
8683
sources.editableContents += challengeFile.editableContents || '';
8784
return sources;
8885
},
8986
{
9087
index: '',
91-
editableContents: '',
92-
original: {}
88+
editableContents: ''
9389
} as Source
9490
);
9591
return source;
@@ -181,8 +177,7 @@ function getWorkerTestRunner(
181177
) {
182178
const code = {
183179
contents: sources.index,
184-
editableContents: sources.editableContents,
185-
original: sources.original
180+
editableContents: sources.editableContents
186181
};
187182

188183
interface TestWorkerExecutor extends WorkerExecutor {

client/src/templates/Challenges/utils/frame.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ export interface Source {
1313
index: string;
1414
contents?: string;
1515
editableContents: string;
16-
original: { [key: string]: string | null };
1716
}
1817

1918
interface Hooks {

client/src/templates/Challenges/utils/python-worker-handler.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ let listener: ((event: MessageEvent) => void) | null = null;
88
type Code = {
99
contents: string;
1010
editableContents: string;
11-
original: string;
1211
};
1312
// We need to keep track of the last code message so we can re-run it if the
1413
// worker is reset.
@@ -102,7 +101,6 @@ export function interruptCodeExecution(): void {
102101
export function runPythonCode(code: {
103102
contents: string;
104103
editableContents: string;
105-
original: string;
106104
}): void {
107105
lastCodeMessage = code;
108106
getPythonWorker().postMessage({ type: 'run', code });

curriculum/test/test-challenges.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,8 +570,7 @@ async function createTestRunner(
570570

571571
const code = {
572572
contents: sources.index,
573-
editableContents: sources.editableContents,
574-
original: sources.original
573+
editableContents: sources.editableContents
575574
};
576575

577576
const buildFunction = buildFunctions[challenge.challengeType];

tools/client-plugins/browser-scripts/frame-runner.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,7 @@ frameDocument.__initTestFrame = initTestFrame;
1111

1212
async function initTestFrame(e: InitTestFrameArg = { code: {} }) {
1313
const code = (e.code.contents || '').slice();
14-
const __file = (id?: string) => {
15-
if (id && e.code.original) {
16-
return e.code.original[id];
17-
} else {
18-
return code;
19-
}
20-
};
14+
2115
const editableContents = (e.code.editableContents || '').slice();
2216
// __testEditable allows test authors to run tests against a transitory dom
2317
// element built using only the code in the editable region.

tools/client-plugins/browser-scripts/index.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export interface InitTestFrameArg {
1818
code: {
1919
contents?: string;
2020
editableContents?: string;
21-
original?: { [id: string]: string | null };
2221
};
2322
getUserInput?: (fileName: string) => string;
2423
loadEnzyme?: () => void;

tools/client-plugins/browser-scripts/python-test-evaluator.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ interface PythonRunEvent extends MessageEvent {
1616
code: {
1717
contents: string;
1818
editableContents: string;
19-
original: { [id: string]: string };
2019
};
2120
firstTest: unknown;
2221
testString: string;

tools/client-plugins/browser-scripts/python-worker.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ interface PythonRunEvent extends MessageEvent {
2121
code: {
2222
contents: string;
2323
editableContents: string;
24-
original: { [id: string]: string };
2524
};
2625
};
2726
}

tools/client-plugins/browser-scripts/test-evaluator.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ interface TestEvaluatorEvent extends MessageEvent {
103103
code: {
104104
contents: string;
105105
editableContents: string;
106-
original: { [id: string]: string };
107106
};
108107
firstTest: unknown;
109108
testString: string;

0 commit comments

Comments
 (0)