From d47a067893ed140b72c7481132ee6484ce1f35f3 Mon Sep 17 00:00:00 2001 From: Nicolas Sutter Date: Wed, 29 Nov 2023 12:40:21 +0100 Subject: [PATCH] fix: fix slack changelog generation --- scripts/slack.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/scripts/slack.ts b/scripts/slack.ts index 47a6b37..3487a36 100644 --- a/scripts/slack.ts +++ b/scripts/slack.ts @@ -2,6 +2,8 @@ import { $fetch, FetchError } from 'ofetch' import { consola } from 'consola' import { readPackage } from 'read-pkg' import stripAnsi from 'strip-ansi' +import { readFile } from 'fs/promises' +import { join } from 'path' const SLACK_NOTIFICATION_URL = process.env.SLACK_NOTIFICATION_URL @@ -13,14 +15,20 @@ async function start() { ) } - const { execaCommand } = await import('execa') - const { version, name: pkgName } = await readPackage() - let { stdout: changelog } = await execaCommand( - 'pnpm changelogen --no-output', + const fullChangelog = await readFile( + join(process.cwd(), 'CHANGELOG.md'), + 'utf-8', ) + let changelog = /(##\sv\d(?:.|\n)+)\n##\sv\d/gm.exec(fullChangelog)?.[1] + + if (!changelog) { + consola.error('Unable to parse changelog, aborting.') + process.exit(0) + } + changelog = stripAnsi(changelog) const text = changelog