MCPcopy Create free account
hub / github.com/TheOdinProject/javascript-exercises / writeExercise

Function writeExercise

generators/writeExercise.js:5–23  ·  view source on GitHub ↗
(exercisePath)

Source from the content-addressed store, hash-verified

3const { splitDirectoryName } = require("./helpers");
4
5async function writeExercise(exercisePath) {
6 const { exerciseName } = splitDirectoryName(exercisePath);
7 const isSolutionFile = exercisePath.includes("/solution");
8 const exerciseContent = `const ${exerciseName} = function() {
9${isSolutionFile ? " // Replace this comment with the solution code" : ""}
10};
11
12// Do not edit below this line
13module.exports = ${exerciseName};
14`;
15
16 await writeFile(
17 join(
18 exercisePath,
19 `${exerciseName}${isSolutionFile ? "-solution" : ""}.js`
20 ),
21 exerciseContent
22 );
23}
24
25module.exports = { writeExercise };

Callers 1

plopFile.jsFile · 0.85

Calls 1

splitDirectoryNameFunction · 0.85

Tested by

no test coverage detected