'use strict';

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

var _chalk = require('chalk');

var _chalk2 = _interopRequireDefault(_chalk);

var _printTools = require('../../utils/print-tools');

var _dateUtils = require('../../utils/date-utils');

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function printCompileError(errObj, socketName) {
  if (errObj.errorType === 'compilationError') {
    if (errObj.error.name === 'EntryModuleNotFoundError') {
      (0, _printTools.echo)();
      (0, _printTools.error)(4)(errObj.error.message);
      (0, _printTools.echo)();
    } else if (errObj.error.name === 'ModuleBuildError' || errObj.error.name === 'ModuleNotFoundError') {
      const rawRequest = _chalk2.default.blue(errObj.error.module.rawRequest);
      if (socketName) {
        (0, _printTools.echo)(7)(`${_chalk2.default.red('deploy error:')} ${(0, _dateUtils.currentTime)()} ${_chalk2.default.blue(socketName)} socket`);
      }
      (0, _printTools.echon)(8)(`${_chalk2.default.red('build error:')} ${(0, _dateUtils.currentTime)()} ${rawRequest}`);
      (0, _printTools.echo)(` ${errObj.error.message.split('\n').join(`\n${(0, _printTools.p)(14)()}`)}`);
    } else {
      (0, _printTools.echo)();
      (0, _printTools.error)(4)(errObj.error.message);
      (0, _printTools.echo)();
    }
  }
  if (errObj.errorType === 'webpackError') {
    (0, _printTools.echo)(6)(`${_chalk2.default.red('webpack error:')} ${(0, _dateUtils.currentTime)()} ${errObj.error.message}`);
  }
}

exports.default = {
  printCompileError
};
module.exports = exports['default'];
//# sourceMappingURL=print.js.map