cfg-test
Version:
In-source testing using Node.js Test Runner
80 lines (78 loc) • 3.14 kB
JavaScript
;
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(
mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod,
enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }),
mod);
// src/core/log.ts
var log_exports = {};
__export(log_exports, {
debug: () => debug,
error: () => error,
warn: () => warn
});
module.exports = __toCommonJS(log_exports);
var import_node_process = __toESM(require("node:process"));
var import_node_util = require("node:util");
var isColorSupported = !("NO_COLOR" in import_node_process.default.env) && ("FOR\
CE_COLOR" in import_node_process.default.env || import_node_process.default.platform ===
"win32" || import_node_process.default.stdout.isTTY);
var isDebugMode = "CFG_TEST_DEBUG" in import_node_process.default.env || "ACT" in
import_node_process.default.env || "DEBUG" in import_node_process.default.env ||
"TRACE" in import_node_process.default.env;
var dim = !isColorSupported ? String : (s) => `\x1B[2m${s}\x1B[22m`;
var red = !isColorSupported ? String : (s) => `\x1B[31m${s}\x1B[39m`;
var yellow = !isColorSupported ? String : (s) => `\x1B[33m${s}\x1B[39m`;
var time = () => (/* @__PURE__ */ new Date()).toLocaleTimeString();
var toStr = (msg) => typeof msg === "object" && msg !== null ? (0, import_node_util.formatWithOptions)(
{ colors: isColorSupported }, "%O", msg) : String(msg);
function log(o, lv, msg) {
for (const m of msg()) {
o.write(`${dim(time())} ${lv} ${dim("[cfg-test]")} ${toStr(m)}
`, "utf8");
}
}
function debug(msg) {
if (isDebugMode) {
log(import_node_process.default.stdout, "DEBUG", msg);
}
}
function error(msg) {
log(import_node_process.default.stderr, red("ERROR"), msg);
}
function warn(msg) {
log(import_node_process.default.stdout, yellow("WARN") + " ", msg);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
debug,
error,
warn
});
//# sourceMappingURL=log.cjs.map