import { includes } from 'lodash';
export default function separate(fullpath) {
  // Filename CAN'T contains spaces.
  fullpath = fullpath.replace(/\s/g, ''); // Path separator

  fullpath = fullpath.replace(/:/g, '/'); // Path cannot empty

  fullpath = fullpath.replace(/^\/+/, '');
  var pathLength = fullpath.lastIndexOf('/') + 1;
  var path = fullpath.substr(0, pathLength);
  var filename = fullpath.substr(pathLength);
  var plainLength = includes(filename, '.') ? filename.lastIndexOf('.') : filename.length;
  var plain = filename.substr(0, plainLength);
  var ext = filename.substr(plainLength);
  var name = path + plain + ext;
  var moduleName = path + plain;
  return {
    path: path,
    plain: plain,
    ext: ext,
    name: name,
    moduleName: moduleName
  };
}