Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Commit

Permalink
fix: fix slack changelog generation
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolassutter committed Nov 29, 2023
1 parent ab8ae28 commit d47a067
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions scripts/slack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down

0 comments on commit d47a067

Please sign in to comment.