var fs = require('fs');
var path = require('path');

module.exports = function (root, opts, pluginOpts) {
    var params = {};
    var cwd = process.cwd();

    if (!opts.src) {
        params.src = root.toString();
    } else {
        var src = path.resolve(cwd, opts.src);
        params.src = fs.readFileSync(src, 'utf8');
    }

    if (opts.dest) {
        params.dest = path.resolve(cwd, opts.dest);
    } else {
        var from = (pluginOpts || {}).from; // for the gulp and grunt
        var output = from ? path.basename(from, '.css') : 'index.html'
        params.dest = path.resolve(cwd, 'styleguide', output);
    }

    params.project = opts.project || 'Style Guide';
    if (opts.showCode === undefined) {
        params.showCode = true;
    } else {
        params.showCode = false;
    }

    var theme;
    if (opts.theme) {
        theme = 'psg-theme-' + opts.theme;
    } else {
        theme = 'psg-theme-default';
    }

    var themePath;
    if (opts.themePath) {
      themePath = opts.themePath;
    } else {
      var module = require.resolve(theme);
      themePath = path.dirname(module)
    }

    try {
      var templateFile = path.resolve(themePath, 'template.ejs');
      params.template = fs.readFileSync(templateFile, 'utf-8');
    } catch (err) {
      throw err;
    }
    try {
      var templateStyle = path.resolve(themePath, 'style.css');
      params.style = fs.readFileSync(templateStyle, 'utf-8');
    } catch (err) {
      throw err;
    }
    return params;
}

@@ -1043,24 +1043,72 @@
 var 
-module = require
+isFind = module.paths.some(function (m) %7B%0A          var p = path
 .res
@@ -1108,24 +1108,27 @@
 ath.resolve(
+m, 
 theme);%0A    
@@ -1133,40 +1133,215 @@
     
-themePath = path.dirname(module)
+    if (!isExists(p)) %7B%0A              return false;%0A          %7D%0A          themePath = p;%0A          return true;%0A      %7D);%0A      if (!isFind) %7B%0A          throw new Error('specify theme is not found');%0A      %7D
 %0A   
@@ -1702,24 +1702,24 @@
  err;%0A    %7D%0A
-
     return p
@@ -1727,8 +1727,145 @@
 rams;%0A%7D%0A
+%0Afunction isExists(dirPath) %7B%0A    try %7B%0A        fs.statSync(dirPath);%0A    %7D catch (err) %7B%0A        return false;%0A    %7D%0A    return true;%0A%7D%0A

fix the search of theme