MCPcopy Create free account
hub / github.com/freeCodeCamp/freeCodeCamp / updateStepTitles

Function updateStepTitles

tools/challenge-helper-scripts/utils.ts:206–230  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

204}
205
206const updateStepTitles = (): void => {
207 const meta = getMetaData();
208
209 const fileNames: string[] = [];
210 fs.readdirSync(getProjectPath()).forEach(fileName => {
211 if (path.extname(fileName).toLowerCase() === '.md') {
212 fileNames.push(fileName);
213 }
214 });
215
216 fileNames.forEach(fileName => {
217 const filePath = `${getProjectPath()}${fileName}`;
218 const frontMatter = matter.read(filePath);
219 const newStepNum =
220 meta.challengeOrder.findIndex(({ id }) => id === frontMatter.data.id) + 1;
221 const title = `Step ${newStepNum}`;
222 const dashedName = `step-${newStepNum}`;
223 const newData = {
224 ...frontMatter.data,
225 title,
226 dashedName
227 };
228 fs.writeFileSync(filePath, matter.stringify(frontMatter.content, newData));
229 });
230};
231
232const updateTaskMarkdownFiles = (): void => {
233 const meta = getMetaData();

Callers 4

deleteStepFunction · 0.85
insertStepFunction · 0.85
utils.test.tsFile · 0.85

Calls 2

getMetaDataFunction · 0.85
getProjectPathFunction · 0.85

Tested by

no test coverage detected