old_contents: var map = require('map-stream');
  var Duo = require('duo');
  
  module.exports = function() {
    var plugins = [].slice.call(arguments);
    var opts = {};
  
    if (plugins.length > 0 && typeof plugins[0] == "object") {
      opts = plugins[0];
      plugins = plugins.slice(1);
    }
  
    // TODO should support array form?
    if (typeof opts.plugins == "object") {
      var plugs = Object.keys(opts.plugins).map(function(name){
        var po = opts.plugins[name];
        return require(name)(po);
      });
      plugins = plugs.concat(plugins);
    }
  
    return function() {
      return map(function(file, cb) {
  
        // Start Duo from root
        // https://github.com/duojs/duo/issues/357
        var duo = Duo(process.cwd()).entry(file.path);
  
        setOptions(duo, opts);
  
        plugins.forEach(function(plugin) {
          duo = duo.use(plugin);
        });
  
        return duo.run(function(err, src) {
            if (err) return cb(err, null);
            file.contents = new Buffer(src, 'utf8');
            return cb(null, file);
        });
      });
    };
  };
  
  // https://github.com/duojs/duo/blob/master/docs/api.md
  function setOptions(duo, opts) {
    if (!!opts.dev || !!opts.development) {
      duo = duo.development(true);
    }
  
    if (!!opts.sourcemap) {
      duo = duo.sourcemap(opts.sourcemap);
    }
  
    if (!!opts.cache) {
      duo = duo.cache(true);
    }
  
    if (!!opts.copy) {
      duo = duo.copy(true);
    }
  
    // TODO support CSV string value
    (opts.globals || []).forEach(function(name) {
      duo = duo.global(name);
    });
  
    if (typeof opts.concurrency !== "undefined") {
      duo = duo.concurrency(opts.concurrency);
    }
  
    if (!!opts.installTo) {
      duo = duo.installTo(opts.installTo);
    }
  
    // TODO nests assets incorrectly, doesn't update paths correctly
    if (!!opts.buildTo) {
      duo = duo.buildTo(opts.buildTo);
    }
  
    // github token
    if (typeof opts.token !== "undefined") {
      duo = duo.token(opts.token);
    }
  
    // TODO buildTo, includes, path, installPath, buildPath
  
    return duo;
  }
  
new_contents: /**
   * Dependencies
   */
  var map = require('map-stream');
  var Duo = require('duo');
  
  /**
   * Options
   *
   * see: https://github.com/duojs/duo/blob/master/docs/api.md
   */
  function setOptions(duo, options) {
    if (!!options.dev || !!options.development) {
      duo = duo.development(true);
    }
  
    if (!!options.sourcemap) {
      duo = duo.sourcemap(options.sourcemap);
    }
  
    if (!!options.cache) {
      duo = duo.cache(true);
    }
  
    if (!!options.copy) {
      duo = duo.copy(true);
    }
  
    if (!!options.standalone) {
      duo = duo.standalone(options.standalone);
    }
  
    if (typeof options.concurrency !== 'undefined') {
      duo = duo.concurrency(options.concurrency);
    }
  
    if (!!options.installTo) {
      duo = duo.installTo(options.installTo);
    }
  
    if (!!options.buildTo) {
      duo = duo.buildTo(options.buildTo);
    }
  
    if (typeof options.token !== 'undefined') {
      duo = duo.token(options.token);
    }
  
    return duo;
  }
  
  /**
   * Export
   */
  module.exports = function() {
    /**
     * Get and assign any arguments
     */
    var args = arguments[0];
    var options = false;
    var plugins = false;
  
    if (args && args.plugins) {
      plugins = args.plugins;
    }
    if (args && args.options) {
      options = args.options;
    }
  
    /**
     * TODO What's going on here? Needs documentation!
     */
    if (plugins) {
      var plugs = Object.keys(plugins).map(function(name) {
        var po = plugins[name];
        return require(name)(po);
      });
      plugins = plugs.concat(plugins);
    }
  
    return function() {
      return map(function(file, cb) {
  
        /**
         * Start Duo from process folder and not from where the file's located
         */
        var duo = Duo(process.cwd()).entry(file.path);
  
        /**
         * Set options to use
         */
        if (options) {
          setOptions(duo, options);
        }
  
        /**
         * Set plugins to use
         */
        if (plugins) {
          plugins.forEach(function(plugin) {
            duo = duo.use(plugin);
          });
        }
  
        /**
         * Run Duo
         */
        return duo.run(function(err, src) {
          if (err) {
            return cb(err, null);
          }
          file.contents = new Buffer(src, 'utf8');
          return cb(null, file);
        });
      });
    };
  };
  
subject: Refactor and add options