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

Function createExerciseDirectoryName

generators/helpers.js:41–50  ·  view source on GitHub ↗
(exerciseName, path)

Source from the content-addressed store, hash-verified

39}
40
41async function createExerciseDirectoryName(exerciseName, path) {
42 const latestExerciseDirectory = await getLatestExerciseDirectory(path);
43 const latestExerciseNumber = parseInt(latestExerciseDirectory.match(/^\d+/));
44
45 if (latestExerciseDirectory === `${latestExerciseNumber}_${exerciseName}`) {
46 throw new Error(`Exercise already exists with name "${exerciseName}"`);
47 }
48
49 return `${latestExerciseNumber + 1}_${exerciseName}`;
50}
51
52module.exports = {
53 getDirsWithExercises,

Callers 1

plopFile.jsFile · 0.85

Calls 1

Tested by

no test coverage detected