"use strict";

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

var _path = _interopRequireDefault(require("path"));

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

/* eslint-disable no-use-before-define */
function getFileType(file) {
  const {
    ext
  } = _path.default.parse(file);

  if (isImageFileExt(ext)) {
    return 'image';
  } else if (isFontFileExt(ext)) {
    return 'font';
  } else if (isVideoFileExt(ext)) {
    return 'video';
  } else if (isAudioFileExt(ext)) {
    return 'audio';
  } else if (ext === '.js') {
    return 'js';
  } else if (ext === '.css') {
    return 'css';
  }

  return null;
}

function isImageFileExt(ext) {
  return ext === '.gif' || ext === '.png' || ext === '.jpg' || ext === '.jpeg' || ext === '.webp' || ext === '.ico';
}

function isFontFileExt(ext) {
  return ext === '.svg' || ext === '.woff' || ext === '.eot' || ext === '.ttf' || ext === '.woff2';
}

function isVideoFileExt(ext) {
  return ext === '.mp4' || ext === '.webm';
}

function isAudioFileExt(ext) {
  return ext === '.ogg' || ext === '.mp3';
}