"use strict";

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

var _chalk = _interopRequireDefault(require("chalk"));

var _updateFilesOnDisk = require("./update-files-on-disk");

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

/**
 * Creates a log message for file operations of a sync run.
 *
 * @param fileOperation The file operation that should be logged
 */
function createFileOperationLogMessage(fileOperation) {
  let logPrefix;

  switch (fileOperation.type) {
    case _updateFilesOnDisk.FileOperationType.Delete:
    case _updateFilesOnDisk.FileOperationType.DeleteSkipped:
      logPrefix = _chalk.default.inverse.red.bold(" DELETED ");
      break;

    case _updateFilesOnDisk.FileOperationType.Place:
      logPrefix = _chalk.default.inverse.green.bold(" CREATED ");
      break;

    case _updateFilesOnDisk.FileOperationType.Update:
      logPrefix = _chalk.default.inverse.blueBright.bold(" UPDATED ");
      break;
  }

  const skipped = fileOperation.type === _updateFilesOnDisk.FileOperationType.DeleteSkipped; // prettier-ignore

  const fileMessage = `${skipped ? "(skipped - " : ""}${fileOperation.relativePath}${skipped ? ")" : ""}`;
  let fullMessage = ` ${logPrefix} ${fileMessage}`;

  if (skipped) {
    fullMessage = _chalk.default.dim(fullMessage);
  }

  return fullMessage;
}