{"version":3,"sources":["utils/logger.ts"],"names":[],"mappings":"AAKA,UAAU,WAAW;IACnB,MAAM,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,iBAAiB;IACzB,WAAW,EAAE,OAAO,CAAC;CACtB;AAqBD,wBAAgB,cAAc,CAC5B,gBAAgB,EAAE,GAAG,EAAE,EACvB,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,GAAE,iBAER,GACA,MAAM,CAgBR;AAED,wBAAgB,KAAK,CACnB,OAAO,EAAE,MAAM,EACf,IAAI,GAAE,WAAgB,EACtB,GAAG,UAAQ,GACV,IAAI,CAMN;AAED,wBAAgB,KAAK,CACnB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,IAAI,GAAE,WAAgB,GACrB,IAAI,CAIN;AAGD,wBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAErC","file":"logger.d.ts","sourcesContent":["/* eslint-disable no-console */\nimport columnify from 'columnify';\nimport chalk from 'chalk';\n\n\ninterface ILoggerOpts {\n  prefix?: string | false;\n  emoji?: string;\n}\n\ninterface IColumnifyOptions {\n  showHeaders: boolean;\n}\n\nfunction fmt(result: string, opts: ILoggerOpts = {}): string {\n  let prefix = opts.prefix || '';\n\n  if (opts.emoji) {\n    prefix = `${opts.emoji}  ${prefix}`;\n  }\n\n  if (prefix) {\n    result = result\n      .trimRight()\n      .split('\\n')\n      .map(line => `${prefix} ${line}`)\n      .join('\\n');\n  }\n\n  return result;\n}\n\n\nexport function trimmedColumns(\n  formattedResults: any[],\n  columns: string[],\n  options: IColumnifyOptions = {\n    showHeaders: true,\n  },\n): string {\n  const str = columnify(formattedResults, {\n    columns,\n    config: {\n      version: {\n        align: 'right',\n      },\n    },\n    ...options,\n  });\n\n  // columnify leaves a lot of trailing space in the last column, remove that here\n  return str\n    .split('\\n')\n    .map((line: string) => line.trimRight())\n    .join('\\n');\n}\n\nexport function write(\n  message: string,\n  opts: ILoggerOpts = {},\n  err = false,\n): void {\n  if (err) {\n    console.error(fmt(message, opts));\n  } else {\n    console.log(fmt(message, opts));\n  }\n}\n\nexport function title(\n  _title: string,\n  subtitle: string,\n  opts: ILoggerOpts = {},\n): void {\n  let str = chalk.bold(_title);\n  if (subtitle) str += ` ${chalk.dim(subtitle)}`;\n  write(str, opts);\n}\n\n\nexport function cmd(str: string): void {\n  write(chalk.bgBlack.magenta(`\\`${str}\\``));\n}\n"]}