var extend = require('util')._extend;
var fs = require('fs');
var path = require('path');
var yml = require('js-yaml');

module.exports = function(opts) {
  // Allow extra data to be loaded
  if (opts.extra) {
    var fileContents = fs.readFileSync(opts.extra);
    switch (path.extname(opts.extra)) {
      case '.json':
        this.searchOptions.extra = JSON.parse(fileContents);
        break;
      case '.yml':
        this.searchOptions.extra = yml.safeLoad(fileContents);
        break;
    }
  }
  else {
    this.searchOptions.extra = [];
  }

  // Allow the order of types to be sorted
  this.searchOptions.sort = opts.sort || [];

  // Allow custom page types to be defined
  this.searchOptions.pageTypes = opts.pageTypes || {};

  return this;
}

@@ -19,22 +19,16 @@
 re('
-util')._
 extend
+')
 ;%0Ava
@@ -148,40 +148,143 @@
 %7B%0A  
-// Allow extra data to be loaded
+this.searchOptions = extend(%7B%0A    extra: %5B%5D,%0A    sort: %5B%5D,%0A    pageTypes: %7B%7D%0A  %7D, opts);%0A%0A  // Load extra results from an external file
 %0A  i
@@ -648,196 +648,8 @@
  %7D%0A%0A
-  // Allow the order of types to be sorted%0A  this.searchOptions.sort = opts.sort %7C%7C %5B%5D;%0A%0A  // Allow custom page types to be defined%0A  this.searchOptions.pageTypes = opts.pageTypes %7C%7C %7B%7D;%0A%0A
   re

Use object extend when calling searchConfig