Skip to content

Commit

Permalink
fix: existing-changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
0xHieu01 committed Mar 12, 2024
1 parent f4f1888 commit 32b7649
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion docs/plugins/changelog-plugin/fetchData.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -94,4 +103,4 @@ async function fetchData(siteConfig) {
}
}

module.exports = fetchData;
module.exports = fetchData;

0 comments on commit 32b7649

Please sign in to comment.