diff --git a/pr-checks/bundle-changelog.ts b/pr-checks/bundle-changelog.ts index 243cbd86b..557a8556c 100755 --- a/pr-checks/bundle-changelog.ts +++ b/pr-checks/bundle-changelog.ts @@ -6,14 +6,13 @@ import * as fs from "node:fs"; -import { getErrorMessage } from "../src/util"; - import { parseChangelog, renderChangelog, UNRELEASED_PLACEHOLDER, } from "./changelog"; import { CHANGELOG_FILE, CLI_BUNDLE_RELEASE_URL_PREFIX } from "./config"; +import { getErrorMessage } from "./util"; export const CLI_VERSION_ENV_VAR = "CLI_VERSION"; export const PR_URL_ENV_VAR = "PR_URL"; diff --git a/pr-checks/prepare-changelog.ts b/pr-checks/prepare-changelog.ts index 9ee89767b..0c89699fc 100755 --- a/pr-checks/prepare-changelog.ts +++ b/pr-checks/prepare-changelog.ts @@ -8,10 +8,9 @@ import * as fs from "node:fs"; import { parseArgs } from "node:util"; -import { getErrorMessage } from "../src/util"; - import { NO_CHANGES_STR, parseChangelog } from "./changelog"; import { CHANGELOG_FILE } from "./config"; +import { getErrorMessage } from "./util"; /** * Prepare the changelog for the new release diff --git a/pr-checks/rollback-changelog.ts b/pr-checks/rollback-changelog.ts index 23b10c935..e0b3634da 100755 --- a/pr-checks/rollback-changelog.ts +++ b/pr-checks/rollback-changelog.ts @@ -7,8 +7,6 @@ import * as fs from "node:fs"; import { parseArgs } from "node:util"; -import { getErrorMessage } from "../src/util"; - import { Changelog, ChangelogSection, @@ -17,6 +15,7 @@ import { renderChangelog, } from "./changelog"; import { CHANGELOG_FILE } from "./config"; +import { getErrorMessage } from "./util"; export interface RollbackChangelogInputs { "target-version": string; diff --git a/pr-checks/util.ts b/pr-checks/util.ts new file mode 100644 index 000000000..353b2a965 --- /dev/null +++ b/pr-checks/util.ts @@ -0,0 +1,9 @@ +/** + * Returns an appropriate message for the error. + * + * If the error is an `Error` instance, this returns the error message without + * an `Error: ` prefix. + */ +export function getErrorMessage(error: unknown): string { + return error instanceof Error ? error.message : String(error); +}