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

Commit

Permalink
Added fail function
Browse files Browse the repository at this point in the history
  • Loading branch information
testersen committed Nov 18, 2023
1 parent 4519cf6 commit 7983c04
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/fail.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import jobSummary from "./summary";
import { rawString, trimIndent } from "./util";

/**
* Set the markdown job/step summary and exit immediately.
* @param content The markdown job summary content.
*/
export function fail(content: string): never;

/**
* Set the markdown job/step summary and exit immediately.
* @param template The markdown job summary template content.
* @param args The arguments to fill into the template.
*/
export function fail(template: TemplateStringsArray, ...args: unknown[]): never;

export function fail(
content: string | TemplateStringsArray,
...args: unknown[]
): never {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const result = "❌ Error:" + trimIndent(content as any, ...(args || []));
jobSummary(result);
console.error(result);
process.exit(1);
}
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ export * from "./setFailed";
export * from "./isDebug";
export * from "./panic";
export * from "./run";
export * from "./fail";
export * from "./reexports";
export * as util from "./util";

0 comments on commit 7983c04

Please sign in to comment.