index.js 433 B

12345678910111213141516171819
  1. /*
  2. Copyright 2012-2015, Yahoo Inc.
  3. Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
  4. */
  5. const path = require('path');
  6. module.exports = {
  7. create(name, cfg) {
  8. cfg = cfg || {};
  9. let Cons;
  10. try {
  11. Cons = require(path.join(__dirname, 'lib', name));
  12. } catch (e) {
  13. Cons = require(name);
  14. }
  15. return new Cons(cfg);
  16. }
  17. };