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