@plugjs/plug
Version:
PlugJS Build System ===================
134 lines (132 loc) • 4.06 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// logging/colors.ts
var colors_exports = {};
__export(colors_exports, {
$blu: () => $blu,
$cyn: () => $cyn,
$grn: () => $grn,
$gry: () => $gry,
$mgt: () => $mgt,
$ms: () => $ms,
$p: () => $p,
$plur: () => $plur,
$red: () => $red,
$t: () => $t,
$und: () => $und,
$wht: () => $wht,
$ylw: () => $ylw
});
module.exports = __toCommonJS(colors_exports);
var import_node_path = require("node:path");
var import_paths = require("../paths.cjs");
var import_options = require("./options.cjs");
var _colors = import_options.logOptions.colors;
import_options.logOptions.on("changed", ({ colors }) => _colors = colors);
var rst = "\x1B[0m";
var und = "\x1B[4m";
var gry = "\x1B[38;5;240m";
var red = "\x1B[38;5;203m";
var grn = "\x1B[38;5;76m";
var ylw = "\x1B[38;5;220m";
var blu = "\x1B[38;5;69m";
var mgt = "\x1B[38;5;213m";
var cyn = "\x1B[38;5;81m";
var wht = "\x1B[1;38;5;255m";
var tsk = "\x1B[38;5;141m";
function colorize(color, string) {
if (!_colors) return `${string}`;
const lines = `${string}`.split("\n");
return lines.map((line) => `${color}${line}${rst}`).join("\n");
}
function $p(path) {
const directory = (0, import_paths.getCurrentWorkingDirectory)();
const relative = (0, import_paths.resolveRelativeChildPath)(directory, path);
const resolved = relative == null ? path : `.${import_node_path.sep}${relative}`;
return _colors ? `${und}${gry}${resolved}${rst}` : `"${resolved}"`;
}
function $t(task, quoted = true) {
return _colors ? `${tsk}${task}${rst}` : quoted ? `"${task}"` : task;
}
function $ms(millis, note) {
let string;
if (millis >= 6e4) {
const minutes = Math.floor(millis / 6e4);
const seconds = Math.floor(millis % 6e4 / 1e3);
string = `${minutes}m ${seconds}s`;
} else if (millis >= 1e4) {
const seconds = Math.floor(millis / 1e3);
const decimal = Math.floor(millis % 1e3 / 100);
string = `${seconds}.${decimal}s`;
} else if (millis >= 1e3) {
const seconds = Math.floor(millis / 1e3);
const decimal = Math.floor(millis % 1e3 / 10);
string = `${seconds}.${decimal}s`;
} else {
string = `${millis}ms`;
}
return note ? _colors ? `${gry}[${note}${gry}|${string}]${rst}` : `[${note}|${string}]` : _colors ? `${gry}[${string}]${rst}` : `[${string}]`;
}
function $gry(string) {
return _colors ? `${gry}${string}${rst}` : string;
}
function $red(string) {
return colorize(red, string);
}
function $grn(string) {
return colorize(grn, string);
}
function $ylw(string) {
return colorize(ylw, string);
}
function $blu(string) {
return colorize(blu, string);
}
function $mgt(string) {
return colorize(mgt, string);
}
function $cyn(string) {
return colorize(cyn, string);
}
function $wht(string) {
return colorize(wht, string);
}
function $und(string) {
return colorize(und, string);
}
function $plur(number, singular, plural, colorize2 = _colors) {
return colorize2 ? number === 1 ? `${$ylw(number)} ${singular}` : `${$ylw(number)} ${plural}` : number === 1 ? `${number} ${singular}` : `${number} ${plural}`;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
$blu,
$cyn,
$grn,
$gry,
$mgt,
$ms,
$p,
$plur,
$red,
$t,
$und,
$wht,
$ylw
});
//# sourceMappingURL=colors.cjs.map