You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.cjs 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var tty = require('tty');
  4. function _interopNamespace(e) {
  5. if (e && e.__esModule) return e;
  6. var n = Object.create(null);
  7. if (e) {
  8. Object.keys(e).forEach(function (k) {
  9. if (k !== 'default') {
  10. var d = Object.getOwnPropertyDescriptor(e, k);
  11. Object.defineProperty(n, k, d.get ? d : {
  12. enumerable: true,
  13. get: function () { return e[k]; }
  14. });
  15. }
  16. });
  17. }
  18. n["default"] = e;
  19. return Object.freeze(n);
  20. }
  21. var tty__namespace = /*#__PURE__*/_interopNamespace(tty);
  22. const {
  23. env = {},
  24. argv = [],
  25. platform = "",
  26. } = typeof process === "undefined" ? {} : process;
  27. const isDisabled = "NO_COLOR" in env || argv.includes("--no-color");
  28. const isForced = "FORCE_COLOR" in env || argv.includes("--color");
  29. const isWindows = platform === "win32";
  30. const isDumbTerminal = env.TERM === "dumb";
  31. const isCompatibleTerminal =
  32. tty__namespace && tty__namespace.isatty && tty__namespace.isatty(1) && env.TERM && !isDumbTerminal;
  33. const isCI =
  34. "CI" in env &&
  35. ("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env);
  36. const isColorSupported =
  37. !isDisabled &&
  38. (isForced || (isWindows && !isDumbTerminal) || isCompatibleTerminal || isCI);
  39. const replaceClose = (
  40. index,
  41. string,
  42. close,
  43. replace,
  44. head = string.substring(0, index) + replace,
  45. tail = string.substring(index + close.length),
  46. next = tail.indexOf(close)
  47. ) => head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
  48. const clearBleed = (index, string, open, close, replace) =>
  49. index < 0
  50. ? open + string + close
  51. : open + replaceClose(index, string, close, replace) + close;
  52. const filterEmpty =
  53. (open, close, replace = open, at = open.length + 1) =>
  54. (string) =>
  55. string || !(string === "" || string === undefined)
  56. ? clearBleed(
  57. ("" + string).indexOf(close, at),
  58. string,
  59. open,
  60. close,
  61. replace
  62. )
  63. : "";
  64. const init = (open, close, replace) =>
  65. filterEmpty(`\x1b[${open}m`, `\x1b[${close}m`, replace);
  66. const colors = {
  67. reset: init(0, 0),
  68. bold: init(1, 22, "\x1b[22m\x1b[1m"),
  69. dim: init(2, 22, "\x1b[22m\x1b[2m"),
  70. italic: init(3, 23),
  71. underline: init(4, 24),
  72. inverse: init(7, 27),
  73. hidden: init(8, 28),
  74. strikethrough: init(9, 29),
  75. black: init(30, 39),
  76. red: init(31, 39),
  77. green: init(32, 39),
  78. yellow: init(33, 39),
  79. blue: init(34, 39),
  80. magenta: init(35, 39),
  81. cyan: init(36, 39),
  82. white: init(37, 39),
  83. gray: init(90, 39),
  84. bgBlack: init(40, 49),
  85. bgRed: init(41, 49),
  86. bgGreen: init(42, 49),
  87. bgYellow: init(43, 49),
  88. bgBlue: init(44, 49),
  89. bgMagenta: init(45, 49),
  90. bgCyan: init(46, 49),
  91. bgWhite: init(47, 49),
  92. blackBright: init(90, 39),
  93. redBright: init(91, 39),
  94. greenBright: init(92, 39),
  95. yellowBright: init(93, 39),
  96. blueBright: init(94, 39),
  97. magentaBright: init(95, 39),
  98. cyanBright: init(96, 39),
  99. whiteBright: init(97, 39),
  100. bgBlackBright: init(100, 49),
  101. bgRedBright: init(101, 49),
  102. bgGreenBright: init(102, 49),
  103. bgYellowBright: init(103, 49),
  104. bgBlueBright: init(104, 49),
  105. bgMagentaBright: init(105, 49),
  106. bgCyanBright: init(106, 49),
  107. bgWhiteBright: init(107, 49),
  108. };
  109. const createColors = ({ useColor = isColorSupported } = {}) =>
  110. useColor
  111. ? colors
  112. : Object.keys(colors).reduce(
  113. (colors, key) => ({ ...colors, [key]: String }),
  114. {}
  115. );
  116. const {
  117. reset,
  118. bold,
  119. dim,
  120. italic,
  121. underline,
  122. inverse,
  123. hidden,
  124. strikethrough,
  125. black,
  126. red,
  127. green,
  128. yellow,
  129. blue,
  130. magenta,
  131. cyan,
  132. white,
  133. gray,
  134. bgBlack,
  135. bgRed,
  136. bgGreen,
  137. bgYellow,
  138. bgBlue,
  139. bgMagenta,
  140. bgCyan,
  141. bgWhite,
  142. blackBright,
  143. redBright,
  144. greenBright,
  145. yellowBright,
  146. blueBright,
  147. magentaBright,
  148. cyanBright,
  149. whiteBright,
  150. bgBlackBright,
  151. bgRedBright,
  152. bgGreenBright,
  153. bgYellowBright,
  154. bgBlueBright,
  155. bgMagentaBright,
  156. bgCyanBright,
  157. bgWhiteBright,
  158. } = createColors();
  159. exports.bgBlack = bgBlack;
  160. exports.bgBlackBright = bgBlackBright;
  161. exports.bgBlue = bgBlue;
  162. exports.bgBlueBright = bgBlueBright;
  163. exports.bgCyan = bgCyan;
  164. exports.bgCyanBright = bgCyanBright;
  165. exports.bgGreen = bgGreen;
  166. exports.bgGreenBright = bgGreenBright;
  167. exports.bgMagenta = bgMagenta;
  168. exports.bgMagentaBright = bgMagentaBright;
  169. exports.bgRed = bgRed;
  170. exports.bgRedBright = bgRedBright;
  171. exports.bgWhite = bgWhite;
  172. exports.bgWhiteBright = bgWhiteBright;
  173. exports.bgYellow = bgYellow;
  174. exports.bgYellowBright = bgYellowBright;
  175. exports.black = black;
  176. exports.blackBright = blackBright;
  177. exports.blue = blue;
  178. exports.blueBright = blueBright;
  179. exports.bold = bold;
  180. exports.createColors = createColors;
  181. exports.cyan = cyan;
  182. exports.cyanBright = cyanBright;
  183. exports.dim = dim;
  184. exports.gray = gray;
  185. exports.green = green;
  186. exports.greenBright = greenBright;
  187. exports.hidden = hidden;
  188. exports.inverse = inverse;
  189. exports.isColorSupported = isColorSupported;
  190. exports.italic = italic;
  191. exports.magenta = magenta;
  192. exports.magentaBright = magentaBright;
  193. exports.red = red;
  194. exports.redBright = redBright;
  195. exports.reset = reset;
  196. exports.strikethrough = strikethrough;
  197. exports.underline = underline;
  198. exports.white = white;
  199. exports.whiteBright = whiteBright;
  200. exports.yellow = yellow;
  201. exports.yellowBright = yellowBright;