Skip to content

Commit

Permalink
fix(config-tools): Added polyfil to support the release version gener…
Browse files Browse the repository at this point in the history
…ator's chalk instance
  • Loading branch information
sullivanpj committed Feb 15, 2024
1 parent 5273623 commit 3cbbabc
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/config-tools/src/utilities/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@ import { LogLevel } from "../types";
import type { StormConfig } from "@storm-software/config";
import { getLogLevel } from "./get-log-level";

// Annoying chalk polyfill to temporarily fix the issue with the `chalk` import
const chalkDefault = {
hex: (_: string) => (message: string) => message,
bgHex: (_: string) => ({
whiteBright: (message: string) => message
}),
whiteBright: (message: string) => message,
bold: {
hex: (_: string) => (message: string) => message,
bgHex: (_: string) => ({
whiteBright: (message: string) => message
}),
whiteBright: (message: string) => message
}
} as any;

/**
* Get the log function for a log level
*
Expand All @@ -14,6 +30,11 @@ export const getLogFn = (
config: Partial<StormConfig> = {},
logLevel: number | LogLevel = LogLevel.INFO
): ((message: string) => void) => {
let _chalk = chalk;
if (!_chalk?.hex || !_chalk?.bold?.hex || !_chalk?.bgHex || !_chalk?.whiteBright) {
_chalk = chalkDefault;
}

if (
(typeof logLevel === "number" &&
(logLevel >= getLogLevel(config.logLevel ?? process.env?.STORM_LOG_LEVEL) ||
Expand Down

0 comments on commit 3cbbabc

Please sign in to comment.