blob: 2b5f4cb759bff6b27044b528e363b7793a9556c6 (
plain)
| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 | const rechoir = require('rechoir');
const isString = require('lodash.isstring');
module.exports = function(eventEmitter, extensions, configPath, cwd) {
  extensions = extensions || {};
  if (!isString(configPath)) {
    return;
  }
  var autoloads = rechoir.prepare(extensions, configPath, cwd, true);
  if (autoloads instanceof Error) {
    autoloads = autoloads.failures;
  }
  if (Array.isArray(autoloads)) {
    autoloads.forEach(function (attempt) {
      if (attempt.error) {
        eventEmitter.emit('requireFail', attempt.moduleName, attempt.error);
      } else {
        eventEmitter.emit('require', attempt.moduleName, attempt.module);
      }
    });
  }
};
 |