MCPcopy
hub / github.com/reapp/reapp / requireFirst

Function requireFirst

lib/findConfig.js:14–31  ·  view source on GitHub ↗
(paths, getDefault)

Source from the content-addressed store, hash-verified

12}
13
14function requireFirst(paths, getDefault) {
15 if (typeof getDefault === 'undefined') {
16 getDefault = function() { return null; };
17 }
18 if (paths.length === 0) {
19 return getDefault();
20 }
21
22 // Try to resolve all alternatives except the last one
23 var path, i;
24 for (i = 0; i < paths.length; i++) {
25 path = paths[i];
26 if (moduleExists(path)) {
27 return require(path);
28 }
29 }
30 return getDefault();
31}
32
33module.exports = function(opts) {
34 var config;

Callers 1

findConfig.jsFile · 0.85

Calls 1

moduleExistsFunction · 0.85

Tested by

no test coverage detected