polymech-astro/packages/imagetools_3/utils/printWarning.js
2025-08-26 12:17:29 +02:00

58 lines
1.1 KiB
JavaScript

// @ts-check
const colours = {
reset: "\x1b[0m",
bright: "\x1b[1m",
dim: "\x1b[2m",
underscore: "\x1b[4m",
blink: "\x1b[5m",
reverse: "\x1b[7m",
hidden: "\x1b[8m",
fg: {
black: "\x1b[30m",
red: "\x1b[31m",
green: "\x1b[32m",
yellow: "\x1b[33m",
blue: "\x1b[34m",
magenta: "\x1b[35m",
cyan: "\x1b[36m",
white: "\x1b[37m",
},
bg: {
black: "\x1b[40m",
red: "\x1b[41m",
green: "\x1b[42m",
yellow: "\x1b[43m",
blue: "\x1b[44m",
magenta: "\x1b[45m",
cyan: "\x1b[46m",
white: "\x1b[47m",
},
};
export default function printWarning({
key = "",
type = "",
message = "",
element = "",
}) {
const flag =
colours.bright + colours.fg.cyan + "[astro-imagetools]" + colours.reset;
const keyLog = key
? " " + colours.bg.yellow + ` ${key} ` + colours.reset
: "";
const messageLog =
colours.fg.yellow +
(message ||
(!element
? `is not a valid ${type} Config Option`
: `can't be defined inside attributes.${element}`)) +
colours.reset;
// console.log(flag + keyLog, messageLog);
}