Skip to content

Commit

Permalink
Handle chalk being undefined
Browse files Browse the repository at this point in the history
`chalk` is sometimes `undefined` in some environments. Can't tell why.
  • Loading branch information
jpwilliams committed Dec 12, 2024
1 parent 0dbcc87 commit 0589152
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion packages/inngest/src/helpers/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ export enum internalEvents {
ScheduledTimer = "inngest/scheduled.timer",
}

export const logPrefix: string = chalk.magenta.bold("[Inngest]");
export const logPrefix: string =
chalk?.magenta.bold("[Inngest]") || "[Inngest]";

export const debugPrefix = "inngest";

Expand Down
12 changes: 7 additions & 5 deletions packages/inngest/src/helpers/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,17 +405,19 @@ export const prettyError = ({
stack,
code,
}: PrettyError): string => {
const { icon, colorFn } = (
const { icon, colorFn = (s: string) => s } = (
{
error: { icon: "❌", colorFn: chalk.red },
warn: { icon: "⚠️", colorFn: chalk.yellow },
error: { icon: "❌", colorFn: chalk?.red },
warn: { icon: "⚠️", colorFn: chalk?.yellow },
} satisfies Record<
NonNullable<PrettyError["type"]>,
{ icon: string; colorFn: (s: string) => string }
{ icon: string; colorFn?: (s: string) => string }
>
)[type];

let header = `${icon} ${chalk.bold.underline(whatHappened.trim())}`;
let header = `${icon} ${
chalk?.bold.underline(whatHappened.trim()) || whatHappened.trim()
}`;
if (stack) {
header +=
"\n" +
Expand Down

0 comments on commit 0589152

Please sign in to comment.