Repository: excalidraw/excalidraw
File: scripts/updateChangelog.js (JavaScript)

Code before:
    if (!supportedTypes.includes(type)) {
      return;
    }
    const messageWithoutType = commit.slice(indexOfColon + 1).trim();
    const messageWithCapitalizeFirst =
      messageWithoutType.charAt(0).toUpperCase() + messageWithoutType.slice(1);
    const prNumber = commit.match(/\(#([0-9]*)\)/)[1];

    // return if the changelog already contains the pr number which would happen for package updates
    if (existingChangeLog.includes(prNumber)) {
      return;
    }
    const prMarkdown = `[#${prNumber}](https://github.com/excalidraw/excalidraw/pull/${prNumber})`;
    const messageWithPRLink = messageWithCapitalizeFirst.replace(
      /\(#[0-9]*\)/,
      prMarkdown,
    );
    commitList[type].push(messageWithPRLink);
  });
  return commitList;
};

const updateChangelog = async () => {
  const commitList = await getLibraryCommitsSinceLastRelease();
  let changelogForLibrary =
    "## Excalidraw Library\n\n**_These section lists the updates made to the excalidraw library and will not affect the integration._**\n\n";
  supportedTypes.forEach((type) => {
    if (commitList[type].length) {
      changelogForLibrary += `### ${headerForType[type]}\n\n`;
      const commits = commitList[type];
      commits.forEach((commit) => {
        changelogForLibrary += `- ${commit}\n\n`;
      });
    }
  });
  changelogForLibrary += "---\n";
  const lastVersionIndex = existingChangeLog.indexOf(`## ${lastVersion}`);
  const updatedContent =
    existingChangeLog.slice(0, lastVersionIndex) +
    changelogForLibrary +
    existingChangeLog.slice(lastVersionIndex + 1);
  fs.writeFileSync(`${excalidrawDir}/CHANGELOG.md`, updatedContent, "utf8");
};

updateChangelog();


Review comment (suggestion):
```suggestion
    "## Excalidraw Library\n\n**_This section lists the updates made to the excalidraw library and will not affect the integration._**\n\n";
```

Code after:
    if (!supportedTypes.includes(type)) {
      return;
    }
    const messageWithoutType = commit.slice(indexOfColon + 1).trim();
    const messageWithCapitalizeFirst =
      messageWithoutType.charAt(0).toUpperCase() + messageWithoutType.slice(1);
    const prNumber = commit.match(/\(#([0-9]*)\)/)[1];

    // return if the changelog already contains the pr number which would happen for package updates
    if (existingChangeLog.includes(prNumber)) {
      return;
    }
    const prMarkdown = `[#${prNumber}](https://github.com/excalidraw/excalidraw/pull/${prNumber})`;
    const messageWithPRLink = messageWithCapitalizeFirst.replace(
      /\(#[0-9]*\)/,
      prMarkdown,
    );
    commitList[type].push(messageWithPRLink);
  });
  return commitList;
};

const updateChangelog = async () => {
  const commitList = await getLibraryCommitsSinceLastRelease();
  let changelogForLibrary =
    "## Excalidraw Library\n\n**_This section lists the updates made to the excalidraw library and will not affect the integration._**\n\n";
  supportedTypes.forEach((type) => {
    if (commitList[type].length) {
      changelogForLibrary += `### ${headerForType[type]}\n\n`;
      const commits = commitList[type];
      commits.forEach((commit) => {
        changelogForLibrary += `- ${commit}\n\n`;
      });
    }
  });
  changelogForLibrary += "---\n";
  const lastVersionIndex = existingChangeLog.indexOf(`## ${lastVersion}`);
  const updatedContent =
    existingChangeLog.slice(0, lastVersionIndex) +
    changelogForLibrary +
    existingChangeLog.slice(lastVersionIndex + 1);
  fs.writeFileSync(`${excalidrawDir}/CHANGELOG.md`, updatedContent, "utf8");
};

updateChangelog();