From 32b76499d973e67586b1aad460b4577a0a9c50fb Mon Sep 17 00:00:00 2001 From: hieu-jan <150573299+hieu-jan@users.noreply.github.com> Date: Tue, 12 Mar 2024 20:54:59 +0900 Subject: [PATCH] fix: existing-changelog --- docs/plugins/changelog-plugin/fetchData.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/plugins/changelog-plugin/fetchData.js b/docs/plugins/changelog-plugin/fetchData.js index 351ab3932..a9b970b3a 100644 --- a/docs/plugins/changelog-plugin/fetchData.js +++ b/docs/plugins/changelog-plugin/fetchData.js @@ -1,5 +1,6 @@ const fs = require('fs'); const path = require('path'); +const fetch = require('node-fetch'); async function fetchData(siteConfig) { const owner = siteConfig.organizationName; @@ -70,6 +71,14 @@ async function fetchData(siteConfig) { // Process the GitHub releases data here for (const release of releases) { const version = release.tag_name; + + // Check if the changelog file already exists for the current version + const existingChangelogPath = path.join(outputDirectory, `changelog-${version}.mdx`); + if (fs.existsSync(existingChangelogPath)) { + console.log(`Changelog for version ${version} already exists. Skipping...`); + continue; + } + const releaseUrl = release.html_url; const issueNumberMatch = release.body.match(/#(\d+)/); const issueNumber = issueNumberMatch ? parseInt(issueNumberMatch[1], 10) : null; @@ -94,4 +103,4 @@ async function fetchData(siteConfig) { } } -module.exports = fetchData; \ No newline at end of file +module.exports = fetchData;