(filePath, oldHref, newHref)
| 547 | } |
| 548 | |
| 549 | function changeLearningTracks(filePath, oldHref, newHref) { |
| 550 | // Can't deserialize and serialize the Yaml because it would lose |
| 551 | // formatting and comments. So regex replace it. |
| 552 | const regex = new RegExp(`- ${oldHref}$`, 'gm') |
| 553 | const oldContent = fs.readFileSync(filePath, 'utf-8') |
| 554 | const newContent = oldContent.replace(regex, `- ${newHref}`) |
| 555 | fs.writeFileSync(filePath, newContent, 'utf-8') |
| 556 | } |