UNPKG

@favware/cliff-jumper

Version:

A small CLI tool to create a semantic release and git-cliff powered Changelog

31 lines 1.08 kB
import { cliffTomlPath } from '#lib/constants'; import { Result, err, ok } from '@sapphire/result'; import { isObject } from '@sapphire/utilities'; import { readFile } from 'fs/promises'; import { parse } from 'smol-toml'; export async function removeHeaderFromChangelogSection(changelogSection) { if (!changelogSection) return undefined; const cliffToml = await parseCliffToml(); return cliffToml.match({ err: () => changelogSection, ok: (tomlContent) => { const header = tomlContent.changelog?.header; if (header) { return changelogSection.replace(header, ''); } return changelogSection; } }); } async function parseCliffToml() { const tomlFile = await readFile(cliffTomlPath, { encoding: 'utf-8' }); const tomlParsed = parse(tomlFile); if (!valueIsObject(tomlParsed)) return err(new Error('Invalid TOML file')); return ok(tomlParsed); } function valueIsObject(value) { return isObject(value); } //# sourceMappingURL=parse-cliff-toml.js.map