'use strict';
var minimatch = require('minimatch');

module.exports = plugin;

function plugin(options) {
  return function(files, metalsmith, done) {
    Object.keys(options).forEach(function(opt) {
      var matcher = minimatch.Minimatch(options[opt].pattern);

      Object.keys(files).forEach(function(file) {
        if (!matcher.match(file)) {
          return;
        }

        files[file].path.name = options[opt].rename;
        files[file].path.base = options[opt].rename;
        var renamedEntry = files[file].path.dir + "/" + options[opt].rename;
        files[renamedEntry] = files[file];
        delete files[file];
      });
    });
    done();
  };
}

'use strict';
var minimatch = require('minimatch'),
    path      = require('path');

module.exports = plugin;

function plugin(options) {
  return function(files, metalsmith, done) {
    Object.keys(options).forEach(function(opt) {
      var matcher = minimatch.Minimatch(options[opt].pattern);

      Object.keys(files).forEach(function(file) {
        if (!matcher.match(file)) {
          return;
        }

        var renamedEntry = path.dirname(file) + "/" + options[opt].rename;
        files[renamedEntry] = files[file];
        delete files[file];
      });
    });
    done();
  };
}

Remove reliance on file path object
Remove reliance on file path object

Re: https://github.com/alex-ketch/metalsmith-renamer/issues/1

This means plugin has to be run before metalsmith-permalink or metalsmith-path so that those files receive correct file.path attributes.
It also means that this plugin now should work even without depending on either of those two plugins.
