src/class/Theme.js
function Theme (name, projectPath, options) {
    if (!name || (typeof name !== 'string') ) {
      return new Error('Param name is required for instantiate a new Theme object');
    }
    if (!options) options = {};

    this.we = we;
    this.hooks = this.we.hooks;
    this.events = this.we.events;

    const self = this;

    this.config = {};

    this.projectPath = projectPath;

    // npm theme path / folder
    this.config.themeFolder = options.themeFolder || path.resolve(projectPath, 'node_modules', name);

    this.config.shortThemeFolder = options.themeFolder || 'node_modules' + '/' + name;

    // load theme module
    delete require.cache[require.resolve(this.config.themeFolder)];
    const npmModule = require(this.config.themeFolder);

    // always initialize all instance properties
    this.name = name;

    const packageJSONPath = this.config.themeFolder+'/package.json';
    delete require.cache[require.resolve(packageJSONPath)];
    this['package.json'] = require(packageJSONPath);
    // shortcut for get installed theme version
    this.version = this['package.json'].version;

    this.templates = {};
    this.layouts = {};
    this.widgets = {};

    this.tplsFolder = path.resolve(self.config.themeFolder, 'templates/server');

    _.merge(this, npmModule);
  }
function Theme (name, projectPath, options) {
    if (!name || (typeof name !== 'string') ) {
      return new Error('Param name is required for instantiate a new Theme object');
    }
    if (!options) options = {};

    this.we = we;
    this.hooks = this.we.hooks;
    this.events = this.we.events;

    const self = this;

    this.config = {};

    this.projectPath = projectPath;

    // npm theme path / folder
    this.config.themeFolder = options.themeFolder || path.resolve(projectPath, 'node_modules', name);

    this.config.shortThemeFolder = options.themeFolder || 'node_modules' + '/' + name;

    // load theme module
    delete require.cache[require.resolve(this.config.themeFolder)];
    const npmModule = require(this.config.themeFolder);

    // always initialize all instance properties
    this.name = name;

    const packageJSONPath = this.config.themeFolder+'/package.json';
    delete require.cache[require.resolve(packageJSONPath)];
    this['package.json'] = require(packageJSONPath);
    // shortcut for get installed theme version
    this.version = this['package.json'].version;

    this.templates = {};
    this.layouts = {};
    this.widgets = {};

    this.tplsFolder = path.resolve(self.config.themeFolder, 'templates/server');

    _.merge(this, npmModule);
  }
We.js theme Class constructor

@param {string} name   theme npm pakage name
@param {string} projectPath project path where the theme is instaled