1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | module.exports = function(file, paths) {
|
11 | var path = require('path');
|
12 |
|
13 | var data = paths.reduce(function(last, filepath) {
|
14 | if (!last) last = load(path.join(filepath, file));
|
15 | return last;
|
16 | }, null);
|
17 |
|
18 | if (!data) throw [
|
19 | "Config file '"+file+"' not found.\n",
|
20 | "Searched in:\n - " + paths.join("\n - ")
|
21 | ].join("");
|
22 |
|
23 | return data;
|
24 | };
|
25 |
|
26 | function load(file) {
|
27 | require('js-yaml');
|
28 | try { require.resolve(file); } catch(e) { return; }
|
29 | return require(file);
|
30 | }
|