Add getErrorMessage to pr-checks-local util.ts to avoid pulling in src/util.ts dependencies

This commit is contained in:
Michael B. Gale
2026-07-24 16:08:18 +01:00
parent cbad145443
commit 0953dc00da
4 changed files with 12 additions and 6 deletions

View File

@@ -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";

View File

@@ -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

View File

@@ -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;

9
pr-checks/util.ts Normal file
View File

@@ -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);
}