'use strict';

var _ = require('lodash'),
    fs = require('fs-extra'),
    uglify = require('uglify-js');

var uglifyOptions = require('./uglify.options.js');

/*----------------------------------------------------------------------------*/

function minify(inpath, outpath, callback, options) {
  if (typeof outpath == 'function') {
    outpath = undefined;
    callback = options;
  }
  if (!outpath) {
    outpath = inpath.replace(/(?=\.js$)/, '.min');
  }
  var output = uglify.minify(inpath, _.defaults(options, uglifyOptions));
  fs.writeFile(outpath, output.code, 'utf-8', callback);
}

module.exports = minify;

@@ -300,87 +300,144 @@
 if (
-typeof outpath == 'function') %7B%0A    outpath = undefined;%0A    callback = options
+_.isFunction(outpath)) %7B%0A    if (_.isObject(callback)) %7B%0A      options = callback;%0A    %7D%0A    callback = outpath;%0A    outpath = undefined
 ;%0A  

Fix argument juggling.