diff --git a/tools/challenge-helper-scripts/create-next-challenge.ts b/tools/challenge-helper-scripts/create-next-challenge.ts index 2bd89fbdb15..09fb31c2bf3 100644 --- a/tools/challenge-helper-scripts/create-next-challenge.ts +++ b/tools/challenge-helper-scripts/create-next-challenge.ts @@ -14,7 +14,7 @@ const createNextChallenge = async () => { const challengeId = new ObjectId(); const challengeText = template({ ...options, challengeId }); - createChallengeFile(options.dashedName, challengeText, path); + createChallengeFile(challengeId.toString(), challengeText, path); const meta = getMetaData(); meta.challengeOrder.push({ diff --git a/tools/challenge-helper-scripts/insert-challenge.ts b/tools/challenge-helper-scripts/insert-challenge.ts index 3d519862774..3522965bede 100644 --- a/tools/challenge-helper-scripts/insert-challenge.ts +++ b/tools/challenge-helper-scripts/insert-challenge.ts @@ -27,7 +27,7 @@ const insertChallenge = async () => { const template = getTemplate(options.challengeType); const challengeId = new ObjectId(); const challengeText = template({ ...options, challengeId }); - createChallengeFile(options.dashedName, challengeText, path); + createChallengeFile(challengeId.toString(), challengeText, path); const meta = getMetaData(); meta.challengeOrder.splice(indexToInsert, 0, { diff --git a/tools/challenge-helper-scripts/utils.test.ts b/tools/challenge-helper-scripts/utils.test.ts index 40724f8e297..004a0d228ee 100644 --- a/tools/challenge-helper-scripts/utils.test.ts +++ b/tools/challenge-helper-scripts/utils.test.ts @@ -119,14 +119,15 @@ describe('Challenge utils helper scripts', () => { }); describe('createChallengeFile util', () => { - it('should create the challenge', () => { + it('should create the challenge using an ObjectId string as the filename', () => { process.env.INIT_CWD = projectPath; const template = 'pretend this is a template'; + const challengeId = new ObjectId(); - createChallengeFile('hi', template); - // - Should write a file with a given name and template + createChallengeFile(challengeId.toString(), template); + // - Should write a file named after the ObjectId with the given template expect(fs.writeFileSync).toHaveBeenCalledWith( - `${projectPath}/hi.md`, + `${projectPath}/${challengeId.toString()}.md`, template ); });