log.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. function _export(target, all) {
  6. for(var name in all)Object.defineProperty(target, name, {
  7. enumerable: true,
  8. get: all[name]
  9. });
  10. }
  11. _export(exports, {
  12. dim: function() {
  13. return dim;
  14. },
  15. default: function() {
  16. return _default;
  17. }
  18. });
  19. const _picocolors = /*#__PURE__*/ _interop_require_default(require("picocolors"));
  20. function _interop_require_default(obj) {
  21. return obj && obj.__esModule ? obj : {
  22. default: obj
  23. };
  24. }
  25. let alreadyShown = new Set();
  26. function log(type, messages, key) {
  27. if (typeof process !== "undefined" && process.env.JEST_WORKER_ID) return;
  28. if (key && alreadyShown.has(key)) return;
  29. if (key) alreadyShown.add(key);
  30. console.warn("");
  31. messages.forEach((message)=>console.warn(type, "-", message));
  32. }
  33. function dim(input) {
  34. return _picocolors.default.dim(input);
  35. }
  36. const _default = {
  37. info (key, messages) {
  38. log(_picocolors.default.bold(_picocolors.default.cyan("info")), ...Array.isArray(key) ? [
  39. key
  40. ] : [
  41. messages,
  42. key
  43. ]);
  44. },
  45. warn (key, messages) {
  46. log(_picocolors.default.bold(_picocolors.default.yellow("warn")), ...Array.isArray(key) ? [
  47. key
  48. ] : [
  49. messages,
  50. key
  51. ]);
  52. },
  53. risk (key, messages) {
  54. log(_picocolors.default.bold(_picocolors.default.magenta("risk")), ...Array.isArray(key) ? [
  55. key
  56. ] : [
  57. messages,
  58. key
  59. ]);
  60. }
  61. };