text: 'use strict';
  Object.defineProperty(exports, '__esModule', {
    value: true
  });
  exports['default'] = convertVinylToVfile;
  // istanbul ignore next
  
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  
  var _path = require('path');
  
  var _path2 = _interopRequireDefault(_path);
  
  var _vfile = require('vfile');
  
  var _vfile2 = _interopRequireDefault(_vfile);
  
  var _vinyl = require('vinyl');
  
  var _vinyl2 = _interopRequireDefault(_vinyl);
  
  /**
   * Convert a Vinyl file to a VFile
   * @param {Vinyl} vinyl - a Vinyl file to convert
   * @throws {TypeError} - if vinyl is not a Vinyl file
   * @return {VFile} - VFile version of vinyl
   */
  
  function convertVinylToVfile(vinyl) {
    var contents = undefined,
        directory = undefined,
        extension = undefined,
        filename = undefined,
        newVinyl = undefined;
  
    // When a "Vinyl file" is passed from a Gulp stream
    // Vinyl.isVinyl(vinyl) returns false.
    // This forces a potential Vinyl file to be a Vinyl file.
    if (vinyl) {
      newVinyl = new _vinyl2['default'](vinyl);
    }
  
    if (!_vinyl2['default'].isVinyl(newVinyl)) {
      throw new TypeError('Expected a Vinyl file');
    }
  
    contents = newVinyl.contents.toString();
    directory = _path2['default'].dirname(newVinyl.path);
    extension = _path2['default'].extname(newVinyl.path).replace('.', '');
    filename = _path2['default'].basename(newVinyl.path, '.' + extension);
  
    return new _vfile2['default']({
      directory: directory,
      filename: filename,
      extension: extension,
      contents: contents
    });
  }
  
  module.exports = exports['default'];