'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var wecomRobot_batchSend = require('../wecom-robot/batch-send.js');
var eslintParser_parse = require('./parse.js');
var eslintParser_robotMsg = require('./robot-msg.js');
require('@babel/runtime/regenerator');
require('../tslib.es6-0d92ef81.js');
require('../wecom-robot/base.js');
require('../wecom-robot/helper.js');
require('axios');
require('../wecom-robot/send-img.js');
require('../nodejs/path.js');
require('../node-img/img.js');
require('../nodejs/crypto.js');
require('../nodejs/fs.js');
require('../nodejs/request.js');
require('@babel/runtime/helpers/toConsumableArray');
require('../fs/fs.js');
require('../nodejs/os.js');
require('../git/git-link.js');
require('../slash/slash.js');

function parseEslintAndSendRobot(_ref) {
  var mrId = _ref.mrId,
    mrUrl = _ref.mrUrl,
    lintReportFile = _ref.lintReportFile,
    repoConfig = _ref.repoConfig,
    robotInfo = _ref.robotInfo;
  var webhookUrl = robotInfo.webhookUrl,
    chatId = robotInfo.chatId;
  var _parseEslintError = eslintParser_parse.parseEslintError({
      lintReportFile: lintReportFile
    }),
    errorMap = _parseEslintError.errorMap,
    total = _parseEslintError.total;
  console.log('[parseEslintAndSendRobot] total: ', total);
  if (!total) return;
  var robotMsg = eslintParser_robotMsg.genRobotMsg({
    mrId: mrId,
    mrUrl: mrUrl,
    errorMap: errorMap,
    total: total,
    repoConfig: repoConfig
  });
  if (webhookUrl) {
    return wecomRobot_batchSend.batchSendWxRobotMarkdown({
      webhookUrl: webhookUrl,
      chatId: chatId,
      content: robotMsg
    });
  }
}

exports.parseEslintAndSendRobot = parseEslintAndSendRobot;
